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>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\"></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)
414 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
415 &IID_IHTMLDocument2
, (void**)&doc
);
416 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
421 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
422 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
424 const IID
* const *piid
;
428 for(piid
= iids
; *piid
; piid
++) {
429 hres
= IDispatch_QueryInterface(iface
, *piid
, (void**)&unk
);
430 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", dbgstr_guid(*piid
), hres
);
432 IUnknown_Release(unk
);
436 #define test_disp(u,id) _test_disp(__LINE__,u,id)
437 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
)
444 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
445 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatch: %08x\n", hres
);
450 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
451 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
452 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
454 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
455 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
457 if(SUCCEEDED(hres
)) {
460 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
461 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
462 ok_(__FILE__
,line
) (IsEqualGUID(&type_attr
->guid
, diid
), "unexpected guid %s\n", dbgstr_guid(&type_attr
->guid
));
464 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
465 ITypeInfo_Release(typeinfo
);
468 IDispatchEx_Release(dispex
);
471 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
472 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
477 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
478 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLElement: %08x\n", hres
);
482 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
483 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
488 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
489 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLElement2: %08x\n", hres
);
493 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
494 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
499 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
500 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLElement3: %08x\n", hres
);
504 #define get_node_iface(u) _get_node_iface(__LINE__,u)
505 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
510 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
511 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLDOMNode: %08x\n", hres
);
515 #define get_img_iface(u) _get_img_iface(__LINE__,u)
516 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
518 IHTMLImgElement
*img
;
521 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
522 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
526 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
527 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
529 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
533 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
534 IHTMLDOMNode_Release(node
);
535 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
536 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", dbgstr_w(name
), exname
);
541 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
542 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
544 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
548 hres
= IHTMLElement_get_tagName(elem
, &tag
);
549 IHTMLElement_Release(elem
);
550 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
551 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", dbgstr_w(tag
), extag
);
556 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
557 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
559 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
560 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
562 if(elem_type_infos
[type
].dispiid
)
563 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
);
566 #define get_node_type(n) _get_node_type(__LINE__,n)
567 static long _get_node_type(unsigned line
, IUnknown
*unk
)
569 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
573 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
574 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
576 IHTMLDOMNode_Release(node
);
581 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
582 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
584 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
585 IHTMLDOMChildrenCollection
*col
= NULL
;
589 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
590 IHTMLDOMNode_Release(node
);
591 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
595 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
596 IDispatch_Release(disp
);
597 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
602 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
603 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, long idx
)
605 IHTMLDOMNode
*node
= NULL
;
609 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
610 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
612 node
= _get_node_iface(line
, (IUnknown
*)disp
);
613 IDispatch_Release(disp
);
618 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
619 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, LPCWSTR name
, LPCWSTR exval
)
627 tmp
= SysAllocString(name
);
628 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
630 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
633 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
634 ok_(__FILE__
,line
) (!lstrcmpW(exval
, V_BSTR(&value
)), "unexpected value %s\n", dbgstr_w(V_BSTR(&value
)));
636 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
639 VariantClear(&value
);
642 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
643 static void _test_elem_offset(unsigned line
, IUnknown
*unk
)
645 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
649 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
650 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
652 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
653 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
655 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
656 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
658 IHTMLElement_Release(elem
);
661 static void test_doc_elem(IHTMLDocument2
*doc
)
664 IHTMLDocument3
*doc3
;
667 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
668 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
670 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
671 IHTMLDocument3_Release(doc3
);
672 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
674 test_node_name((IUnknown
*)elem
, "HTML");
675 test_elem_tag((IUnknown
*)elem
, "HTML");
677 IHTMLElement_Release(elem
);
680 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
681 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
684 IHTMLDocument3
*doc3
;
687 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
688 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
689 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
690 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
691 IHTMLDocument3_Release(doc3
);
696 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
697 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
702 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
703 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
704 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", dbgstr_w(bstr
));
708 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
709 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
715 hres
= IHTMLOptionElement_put_text(option
, bstr
);
717 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
719 _test_option_text(line
, option
, text
);
722 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
723 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
728 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
729 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
730 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", dbgstr_w(bstr
));
734 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
735 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
740 bstr
= a2bstr(value
);
741 hres
= IHTMLOptionElement_put_value(option
, bstr
);
743 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
745 _test_option_value(line
, option
, value
);
748 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
749 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
750 const char *txt
, const char *val
)
752 IHTMLOptionElementFactory
*factory
;
753 IHTMLOptionElement
*option
;
754 IHTMLWindow2
*window
;
755 VARIANT text
, value
, empty
;
758 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
759 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
761 hres
= IHTMLWindow2_get_Option(window
, &factory
);
762 IHTMLWindow2_Release(window
);
763 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
765 V_VT(&text
) = VT_BSTR
;
766 V_BSTR(&text
) = a2bstr(txt
);
767 V_VT(&value
) = VT_BSTR
;
768 V_BSTR(&value
) = a2bstr(val
);
769 V_VT(&empty
) = VT_EMPTY
;
771 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
772 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
774 IHTMLOptionElementFactory_Release(factory
);
776 VariantClear(&value
);
778 _test_option_text(line
, option
, txt
);
779 _test_option_value(line
, option
, val
);
784 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
785 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, long length
)
787 long len
= 0xdeadbeef;
790 hres
= IHTMLSelectElement_get_length(select
, &len
);
791 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
792 ok_(__FILE__
,line
) (len
== length
, "len=%ld, expected %ld\n", len
, length
);
795 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
796 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, long index
)
798 long idx
= 0xdeadbeef;
801 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
802 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
803 ok_(__FILE__
,line
) (idx
== index
, "idx=%ld, expected %ld\n", idx
, index
);
806 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
807 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, long index
)
811 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
812 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
813 _test_select_selidx(line
, select
, index
);
816 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
817 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
822 hres
= IHTMLSelectElement_get_value(select
, &val
);
823 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
825 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", dbgstr_w(val
));
827 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", dbgstr_w(val
));
830 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
831 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
837 hres
= IHTMLSelectElement_put_value(select
, bstr
);
839 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
842 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
843 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
848 hres
= IHTMLSelectElement_get_type(select
, &type
);
849 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
850 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", dbgstr_w(type
), extype
);
853 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
854 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
859 hres
= IHTMLTxtRange_get_text(range
, &text
);
860 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
863 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
864 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=\"%s\", expected \"%s\"\n", dbgstr_w(text
), extext
);
866 ok_(__FILE__
, line
) (text
== NULL
, "text=\"%s\", expected NULL\n", dbgstr_w(text
));
873 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
874 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
878 hres
= IHTMLTxtRange_collapse(range
, b
);
879 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
880 _test_range_text(line
, range
, NULL
);
883 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
884 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
885 VARIANT_BOOL exb
, const char *extext
)
887 VARIANT_BOOL b
= 0xe0e0;
890 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
891 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
892 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
893 _test_range_text(line
, range
, extext
);
896 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
897 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, long cnt
, long excnt
)
902 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
903 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
904 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
905 _test_range_text(line
, range
, NULL
);
908 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
909 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
910 LPWSTR unit
, long cnt
, long excnt
)
915 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
916 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
917 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
920 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
921 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, long cnt
, long excnt
)
926 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
927 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
928 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
931 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
932 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
935 BSTR bstr
= a2bstr(text
);
937 hres
= IHTMLTxtRange_put_text(range
, bstr
);
938 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
940 _test_range_text(line
, range
, NULL
);
943 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
944 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
950 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
951 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
952 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
955 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
956 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
962 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
963 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
964 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
967 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
968 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
969 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
972 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
973 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
977 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
978 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
983 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
984 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
986 _test_elem_type(line
, (IUnknown
*)elem
, type
);
988 IHTMLElement_Release(elem
);
991 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
992 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
993 const elem_type_t
*elem_types
, long exlen
)
995 IHTMLElementCollection
*col
;
1002 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
1003 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
1005 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
);
1007 hres
= IHTMLElementCollection_get_length(col
, &len
);
1008 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1009 ok_(__FILE__
,line
) (len
== exlen
, "len=%ld, expected %ld\n", len
, exlen
);
1014 V_VT(&index
) = VT_EMPTY
;
1015 V_VT(&name
) = VT_I4
;
1017 for(i
=0; i
<len
; i
++) {
1019 disp
= (void*)0xdeadbeef;
1020 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1021 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1022 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
1023 if(FAILED(hres
) || !disp
)
1026 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
1027 IDispatch_Release(disp
);
1031 disp
= (void*)0xdeadbeef;
1032 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1033 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
1034 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1037 disp
= (void*)0xdeadbeef;
1038 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1039 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1040 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1042 IHTMLElementCollection_Release(col
);
1045 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1046 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, long exlen
)
1048 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1049 IHTMLElementCollection
*col
= NULL
;
1050 elem_type_t
*types
= NULL
;
1055 tmp
= a2bstr(elem_type_infos
[type
].tag
);
1056 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
1058 IHTMLElement2_Release(elem
);
1059 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
1060 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
1063 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
1064 for(i
=0; i
<exlen
; i
++)
1068 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
1070 HeapFree(GetProcessHeap(), 0, types
);
1073 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1074 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
1079 hres
= IHTMLElement_get_innerText(elem
, &text
);
1080 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
1081 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
1082 dbgstr_w(text
), extext
);
1083 SysFreeString(text
);
1086 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1087 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
1089 IHTMLDOMChildrenCollection
*col
;
1094 hres
= IHTMLElement_put_innerText(elem
, str
);
1095 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
1098 _test_elem_innertext(line
, elem
, text
);
1101 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
1102 ok(col
!= NULL
, "col == NULL\n");
1104 long length
= 0, type
;
1107 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
1108 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1109 ok(length
== 1, "length = %ld\n", length
);
1111 node
= _get_child_item(line
, col
, 0);
1112 ok(node
!= NULL
, "node == NULL\n");
1114 type
= _get_node_type(line
, (IUnknown
*)node
);
1115 ok(type
== 3, "type=%ld\n", type
);
1116 IHTMLDOMNode_Release(node
);
1119 IHTMLDOMChildrenCollection_Release(col
);
1124 #define get_first_child(n) _get_first_child(__LINE__,n)
1125 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
1127 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1128 IHTMLDOMNode
*child
= NULL
;
1131 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
1132 IHTMLDOMNode_Release(node
);
1133 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
1138 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1139 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1141 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1142 VARIANT_BOOL b
= 0xdead;
1145 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
1146 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
1147 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
1149 IHTMLDOMNode_Release(node
);
1152 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1153 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
1155 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1156 IHTMLDOMNode
*parent
;
1159 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
1160 IHTMLDOMNode_Release(node
);
1161 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
1166 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1167 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
1169 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1170 IHTMLElement
*parent
;
1173 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
1174 IHTMLElement_Release(elem
);
1175 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1180 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1181 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1183 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1184 VARIANT_BOOL disabled
= 100;
1188 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
1189 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1190 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1191 IHTMLElement3_Release(elem3
);
1194 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1195 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1197 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1201 hres
= IHTMLElement3_put_disabled(elem3
, b
);
1202 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1204 IHTMLElement3_Release(elem3
);
1205 _test_elem3_get_disabled(line
, unk
, b
);
1208 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1209 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
1211 VARIANT_BOOL disabled
= 100;
1214 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
1215 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1216 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1218 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
1221 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1222 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
1226 hres
= IHTMLSelectElement_put_disabled(select
, b
);
1227 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1229 _test_select_get_disabled(line
, select
, b
);
1232 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1233 static long _elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
1235 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1236 IHTMLTextContainer
*txtcont
;
1237 long l
= -1, l2
= -1;
1240 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
1241 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
1242 IHTMLElement2_Release(elem
);
1244 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1245 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1247 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
1248 IHTMLTextContainer_Release(txtcont
);
1249 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %ld\n", l2
);
1250 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %ld, expected %ld\n", l2
, l
);
1255 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1256 static long _elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
1258 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1259 IHTMLTextContainer
*txtcont
;
1260 long l
= -1, l2
= -1;
1263 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
1264 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
1265 IHTMLElement2_Release(elem
);
1267 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1268 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1270 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
1271 IHTMLTextContainer_Release(txtcont
);
1272 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %ld\n", l2
);
1273 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %ld, expected %ld\n", l2
, l
);
1278 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1279 static long _elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
1281 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1282 IHTMLTextContainer
*txtcont
;
1283 long l
= -1, l2
= -1;
1286 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
1287 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1288 IHTMLElement2_Release(elem
);
1290 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1291 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1293 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
1294 IHTMLTextContainer_Release(txtcont
);
1295 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %ld\n", l2
);
1296 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %ld, expected %ld\n", l2
, l
);
1301 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1302 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
1304 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1305 IHTMLTextContainer
*txtcont
;
1306 long l
= -1, l2
= -1;
1309 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
1310 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
1312 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
1313 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1314 IHTMLElement2_Release(elem
);
1316 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1317 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1319 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
1320 IHTMLTextContainer_Release(txtcont
);
1321 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %ld\n", l2
);
1322 ok(l
== l2
, "unexpected left %ld, expected %ld\n", l2
, l
);
1325 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1326 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
)
1328 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1332 hres
= IHTMLImgElement_get_src(img
, &src
);
1333 IHTMLImgElement_Release(img
);
1334 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
1335 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", dbgstr_w(src
), exsrc
);
1339 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1340 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
1342 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1347 hres
= IHTMLImgElement_put_src(img
, tmp
);
1348 IHTMLImgElement_Release(img
);
1350 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
1352 _test_img_src(line
, unk
, src
);
1355 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1356 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
1358 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1362 hres
= IHTMLImgElement_get_alt(img
, &alt
);
1363 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
1365 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", dbgstr_w(alt
));
1367 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
1371 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1372 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
1374 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1379 hres
= IHTMLImgElement_put_alt(img
, tmp
);
1380 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
1383 _test_img_alt(line
, unk
, alt
);
1386 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1387 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
1389 VARIANT_BOOL disabled
= 100;
1392 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
1393 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1394 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1396 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
1399 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1400 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
1404 hres
= IHTMLInputElement_put_disabled(input
, b
);
1405 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1407 _test_input_get_disabled(line
, input
, b
);
1410 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1411 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
1413 VARIANT_BOOL checked
= 100;
1416 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
1417 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
1418 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
1421 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1422 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
1426 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
1427 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
1429 _test_input_get_defaultchecked(line
, input
, b
);
1432 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1433 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
1435 VARIANT_BOOL checked
= 100;
1438 hres
= IHTMLInputElement_get_checked(input
, &checked
);
1439 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
1440 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
1443 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1444 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
1448 hres
= IHTMLInputElement_put_checked(input
, b
);
1449 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
1451 _test_input_get_checked(line
, input
, b
);
1454 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1455 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1457 IHTMLInputElement
*input
;
1461 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
1462 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
1466 hres
= IHTMLInputElement_get_value(input
, &bstr
);
1467 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1469 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", dbgstr_w(bstr
));
1471 ok_(__FILE__
,line
) (!exval
, "exval != NULL\n");
1472 SysFreeString(bstr
);
1473 IHTMLInputElement_Release(input
);
1476 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1477 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
1479 IHTMLInputElement
*input
;
1483 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
1484 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
1489 hres
= IHTMLInputElement_get_value(input
, &bstr
);
1490 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1491 SysFreeString(bstr
);
1492 IHTMLInputElement_Release(input
);
1495 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1496 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
1498 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1499 BSTR
class = (void*)0xdeadbeef;
1502 hres
= IHTMLElement_get_className(elem
, &class);
1503 IHTMLElement_Release(elem
);
1504 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
1506 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", dbgstr_w(class));
1508 ok_(__FILE__
,line
) (!class, "class != NULL\n");
1509 SysFreeString(class);
1512 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1513 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
1515 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
1519 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
1520 IHTMLElement2_Release(elem2
);
1521 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
1522 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
1525 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1526 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
1528 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
1531 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
1532 IHTMLElement2_Release(elem2
);
1533 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
1535 _test_elem_tabindex(line
, unk
, index
);
1538 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1539 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
1541 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1545 tmp
= class ? a2bstr(class) : NULL
;
1546 hres
= IHTMLElement_put_className(elem
, tmp
);
1547 IHTMLElement_Release(elem
);
1548 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
1551 _test_elem_class(line
, unk
, class);
1554 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1555 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
1557 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1558 BSTR id
= (void*)0xdeadbeef;
1561 hres
= IHTMLElement_get_id(elem
, &id
);
1562 IHTMLElement_Release(elem
);
1563 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
1566 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", dbgstr_w(id
));
1568 ok_(__FILE__
,line
) (!id
, "id=%s\n", dbgstr_w(id
));
1573 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1574 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
1576 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1577 BSTR tmp
= a2bstr(new_id
);
1580 hres
= IHTMLElement_put_id(elem
, tmp
);
1581 IHTMLElement_Release(elem
);
1583 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
1585 _test_elem_id(line
, unk
, new_id
);
1588 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1589 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
1591 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1595 hres
= IHTMLElement_get_title(elem
, &title
);
1596 IHTMLElement_Release(elem
);
1597 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
1599 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", dbgstr_w(title
));
1601 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", dbgstr_w(title
));
1603 SysFreeString(title
);
1606 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1607 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
1609 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1613 tmp
= a2bstr(title
);
1614 hres
= IHTMLElement_put_title(elem
, tmp
);
1615 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
1617 IHTMLElement_Release(elem
);
1621 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1622 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
1624 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1628 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
1629 IHTMLDOMNode_Release(node
);
1630 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
1633 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
1634 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", dbgstr_w(V_BSTR(&var
)));
1636 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
1642 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
1643 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
1645 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1649 V_VT(&var
) = VT_BSTR
;
1650 V_BSTR(&var
) = a2bstr(val
);
1652 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
1653 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
1654 IHTMLDOMNode_Release(node
);
1658 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
1659 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
1661 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1665 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
1666 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
1667 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
1668 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
1670 IHTMLElement2_Release(elem
);
1673 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
1674 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
1676 IHTMLElement
*elem
= NULL
;
1681 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
1682 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
1683 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
1688 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
1689 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
1691 IHTMLDocument3
*doc3
;
1692 IHTMLDOMNode
*node
= NULL
;
1696 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1697 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
1700 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
1701 IHTMLDocument3_Release(doc3
);
1702 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
1703 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
1708 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
1709 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
1711 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
1712 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
1713 IHTMLDOMNode
*new_child
= NULL
;
1716 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
1717 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
1718 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
1719 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
1721 IHTMLDOMNode_Release(node
);
1722 IHTMLDOMNode_Release(child
);
1727 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
1728 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
1730 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
1731 IHTMLDOMNode
*new_child
= NULL
;
1734 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
1735 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
1736 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
1737 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
1739 IHTMLDOMNode_Release(node
);
1744 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
1745 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
1747 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1748 IHTMLDOMNode
*new_node
= NULL
;
1751 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
1752 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
1753 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
1754 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
1756 IHTMLDOMNode_Release(node
);
1757 IHTMLDOMNode_Release(new_node
);
1760 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
1761 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
1766 hres
= IHTMLDocument2_get_title(doc
, &title
);
1767 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
1768 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", dbgstr_w(title
));
1769 SysFreeString(title
);
1772 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
1773 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
1778 tmp
= a2bstr(title
);
1779 hres
= IHTMLDocument2_put_title(doc
, tmp
);
1780 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
1784 static void test_elem_col_item(IHTMLElementCollection
*col
, LPCWSTR n
,
1785 const elem_type_t
*elem_types
, long len
)
1788 VARIANT name
, index
;
1792 V_VT(&index
) = VT_EMPTY
;
1793 V_VT(&name
) = VT_BSTR
;
1794 V_BSTR(&name
) = SysAllocString(n
);
1796 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1797 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1799 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
1800 IDispatch_Release(disp
);
1801 ok(hres
== S_OK
, "Could not get IHTMLElementCollection interface: %08x\n", hres
);
1805 V_VT(&index
) = VT_I4
;
1807 for(i
=0; i
<len
; i
++) {
1809 disp
= (void*)0xdeadbeef;
1810 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1811 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1812 ok(disp
!= NULL
, "disp == NULL\n");
1813 if(FAILED(hres
) || !disp
)
1816 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
1818 IDispatch_Release(disp
);
1822 disp
= (void*)0xdeadbeef;
1823 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1824 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1825 ok(disp
== NULL
, "disp != NULL\n");
1828 disp
= (void*)0xdeadbeef;
1829 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1830 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1831 ok(disp
== NULL
, "disp != NULL\n");
1834 SysFreeString(V_BSTR(&name
));
1837 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, LPCWSTR id
, BOOL expect_success
)
1839 IHTMLElementCollection
*col
;
1841 IDispatch
*disp
= (void*)0xdeadbeef;
1842 VARIANT name
, index
;
1845 hres
= IHTMLDocument2_get_all(doc
, &col
);
1846 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1847 ok(col
!= NULL
, "col == NULL\n");
1848 if(FAILED(hres
) || !col
)
1851 V_VT(&index
) = VT_EMPTY
;
1852 V_VT(&name
) = VT_BSTR
;
1853 V_BSTR(&name
) = SysAllocString(id
);
1855 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1856 IHTMLElementCollection_Release(col
);
1857 SysFreeString(V_BSTR(&name
));
1858 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1859 if(!expect_success
) {
1860 ok(disp
== NULL
, "disp != NULL\n");
1864 ok(disp
!= NULL
, "disp == NULL\n");
1868 elem
= get_elem_iface((IUnknown
*)disp
);
1869 IDispatch_Release(disp
);
1874 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, LPCWSTR id
)
1876 IHTMLDocument3
*doc3
;
1881 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1882 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
1884 tmp
= SysAllocString(id
);
1885 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
1887 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", dbgstr_w(id
), hres
);
1889 IHTMLDocument3_Release(doc3
);
1894 static void test_select_elem(IHTMLSelectElement
*select
)
1896 test_select_type(select
, "select-one");
1897 test_select_length(select
, 2);
1898 test_select_selidx(select
, 0);
1899 test_select_put_selidx(select
, 1);
1901 test_select_set_value(select
, "val1");
1902 test_select_value(select
, "val1");
1904 test_select_get_disabled(select
, VARIANT_FALSE
);
1905 test_select_set_disabled(select
, VARIANT_TRUE
);
1906 test_select_set_disabled(select
, VARIANT_FALSE
);
1909 static void test_create_option_elem(IHTMLDocument2
*doc
)
1911 IHTMLOptionElement
*option
;
1913 option
= create_option_elem(doc
, "test text", "test value");
1915 test_option_put_text(option
, "new text");
1916 test_option_put_value(option
, "new value");
1918 IHTMLOptionElement_Release(option
);
1921 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
1923 IHTMLBodyElement
*body
;
1924 IHTMLTxtRange
*range
;
1928 hres
= IHTMLDocument2_get_body(doc
, &elem
);
1929 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1931 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
1932 IHTMLElement_Release(elem
);
1934 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
1935 IHTMLBodyElement_Release(body
);
1936 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
1941 static void test_txtrange(IHTMLDocument2
*doc
)
1943 IHTMLTxtRange
*body_range
, *range
, *range2
;
1944 IHTMLSelectionObject
*selection
;
1945 IDispatch
*disp_range
;
1948 body_range
= test_create_body_range(doc
);
1950 test_range_text(body_range
, "test abc 123\r\nit's text");
1952 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1953 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1955 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
1956 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1957 test_range_isequal(range
, range2
, VARIANT_TRUE
);
1959 test_range_text(range
, "test abc 123\r\nit's text");
1960 test_range_text(body_range
, "test abc 123\r\nit's text");
1962 test_range_collapse(range
, TRUE
);
1963 test_range_isequal(range
, range2
, VARIANT_FALSE
);
1964 test_range_inrange(range
, range2
, VARIANT_FALSE
);
1965 test_range_inrange(range2
, range
, VARIANT_TRUE
);
1966 IHTMLTxtRange_Release(range2
);
1968 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1969 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
1970 test_range_move(range
, characterW
, 2, 2);
1971 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1973 test_range_collapse(range
, FALSE
);
1974 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
1976 test_range_collapse(range
, FALSE
);
1977 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
1978 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
1979 test_range_move(range
, characterW
, 2, 2);
1980 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
1981 test_range_moveend(range
, characterW
, -5, -5);
1982 test_range_text(range
, NULL
);
1983 test_range_moveend(range
, characterW
, 3, 3);
1984 test_range_text(range
, "c 1");
1985 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
1986 test_range_collapse(range
, TRUE
);
1987 test_range_move(range
, characterW
, 4, 4);
1988 test_range_moveend(range
, characterW
, 1, 1);
1989 test_range_text(range
, " ");
1990 test_range_move(range
, wordW
, 1, 1);
1991 test_range_moveend(range
, characterW
, 2, 2);
1992 test_range_text(range
, "ab");
1994 IHTMLTxtRange_Release(range
);
1996 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1997 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1999 test_range_text(range
, "test abc 123\r\nit's text");
2000 test_range_move(range
, characterW
, 3, 3);
2001 test_range_moveend(range
, characterW
, 1, 1);
2002 test_range_text(range
, "t");
2003 test_range_moveend(range
, characterW
, 3, 3);
2004 test_range_text(range
, "t ab");
2005 test_range_moveend(range
, characterW
, -2, -2);
2006 test_range_text(range
, "t ");
2007 test_range_move(range
, characterW
, 6, 6);
2008 test_range_moveend(range
, characterW
, 3, 3);
2009 test_range_text(range
, "123");
2010 test_range_moveend(range
, characterW
, 2, 2);
2011 test_range_text(range
, "123\r\ni");
2013 IHTMLTxtRange_Release(range
);
2015 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2016 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2018 test_range_move(range
, wordW
, 1, 1);
2019 test_range_moveend(range
, characterW
, 2, 2);
2020 test_range_text(range
, "ab");
2022 test_range_move(range
, characterW
, -2, -2);
2023 test_range_moveend(range
, characterW
, 2, 2);
2024 test_range_text(range
, "t ");
2026 test_range_move(range
, wordW
, 3, 3);
2027 test_range_move(range
, wordW
, -2, -2);
2028 test_range_moveend(range
, characterW
, 2, 2);
2029 test_range_text(range
, "ab");
2031 test_range_move(range
, characterW
, -6, -5);
2032 test_range_moveend(range
, characterW
, -1, 0);
2033 test_range_moveend(range
, characterW
, -6, 0);
2034 test_range_move(range
, characterW
, 2, 2);
2035 test_range_moveend(range
, characterW
, 2, 2);
2036 test_range_text(range
, "st");
2037 test_range_moveend(range
, characterW
, -6, -4);
2038 test_range_moveend(range
, characterW
, 2, 2);
2040 IHTMLTxtRange_Release(range
);
2042 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2043 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2045 test_range_move(range
, wordW
, 2, 2);
2046 test_range_moveend(range
, characterW
, 2, 2);
2047 test_range_text(range
, "12");
2049 test_range_move(range
, characterW
, 15, 14);
2050 test_range_move(range
, characterW
, -2, -2);
2051 test_range_moveend(range
, characterW
, 3, 2);
2052 test_range_text(range
, "t");
2053 test_range_moveend(range
, characterW
, -1, -1);
2054 test_range_text(range
, "t");
2055 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
2056 test_range_move(range
, characterW
, -2, -2);
2057 test_range_moveend(range
, characterW
, 2, 2);
2058 test_range_text(range
, "s ");
2059 test_range_move(range
, characterW
, 100, 7);
2060 test_range_move(range
, wordW
, 1, 0);
2061 test_range_move(range
, characterW
, -2, -2);
2062 test_range_moveend(range
, characterW
, 3, 2);
2063 test_range_text(range
, "t");
2065 IHTMLTxtRange_Release(range
);
2067 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2068 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2070 test_range_collapse(range
, TRUE
);
2071 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
2072 test_range_put_text(range
, "word");
2073 test_range_text(body_range
, "wordabc 123\r\nit's text");
2074 test_range_text(range
, NULL
);
2075 test_range_moveend(range
, characterW
, 3, 3);
2076 test_range_text(range
, "abc");
2077 test_range_movestart(range
, characterW
, -2, -2);
2078 test_range_text(range
, "rdabc");
2079 test_range_movestart(range
, characterW
, 3, 3);
2080 test_range_text(range
, "bc");
2081 test_range_movestart(range
, characterW
, 4, 4);
2082 test_range_text(range
, NULL
);
2083 test_range_movestart(range
, characterW
, -3, -3);
2084 test_range_text(range
, "c 1");
2085 test_range_movestart(range
, characterW
, -7, -6);
2086 test_range_text(range
, "wordabc 1");
2087 test_range_movestart(range
, characterW
, 100, 22);
2088 test_range_text(range
, NULL
);
2090 IHTMLTxtRange_Release(range
);
2091 IHTMLTxtRange_Release(body_range
);
2093 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
2094 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
2096 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
2097 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
2098 IHTMLSelectionObject_Release(selection
);
2100 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
2101 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
2102 IDispatch_Release(disp_range
);
2104 test_range_text(range
, NULL
);
2105 test_range_moveend(range
, characterW
, 3, 3);
2106 test_range_text(range
, "wor");
2107 test_range_parent(range
, ET_BODY
);
2108 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
2109 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
2110 test_range_move(range
, characterW
, 3, 3);
2111 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
2112 test_range_moveend(range
, characterW
, -4, -4);
2113 test_range_put_text(range
, "abc def ");
2114 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
2115 test_range_move(range
, wordW
, 1, 1);
2116 test_range_movestart(range
, characterW
, -1, -1);
2117 test_range_text(range
, " ");
2118 test_range_move(range
, wordW
, 1, 1);
2119 test_range_moveend(range
, characterW
, 3, 3);
2120 test_range_text(range
, "def");
2121 test_range_put_text(range
, "xyz");
2122 test_range_moveend(range
, characterW
, 1, 1);
2123 test_range_move(range
, wordW
, 1, 1);
2124 test_range_moveend(range
, characterW
, 2, 2);
2125 test_range_text(range
, "ab");
2127 IHTMLTxtRange_Release(range
);
2130 static void test_txtrange2(IHTMLDocument2
*doc
)
2132 IHTMLTxtRange
*range
;
2134 range
= test_create_body_range(doc
);
2136 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2137 test_range_move(range
, characterW
, 5, 5);
2138 test_range_moveend(range
, characterW
, 1, 1);
2139 test_range_text(range
, "2");
2140 test_range_move(range
, characterW
, -3, -3);
2141 test_range_moveend(range
, characterW
, 3, 3);
2142 test_range_text(range
, "c\r\n\r\n1");
2143 test_range_collapse(range
, VARIANT_FALSE
);
2144 test_range_moveend(range
, characterW
, 4, 4);
2145 test_range_text(range
, "23");
2146 test_range_moveend(range
, characterW
, 1, 1);
2147 test_range_text(range
, "23\r\n\r\n\r\nd");
2148 test_range_moveend(range
, characterW
, -1, -1);
2149 test_range_text(range
, "23");
2150 test_range_moveend(range
, characterW
, -1, -1);
2151 test_range_text(range
, "23");
2152 test_range_moveend(range
, characterW
, -2, -2);
2153 test_range_text(range
, "2");
2155 IHTMLTxtRange_Release(range
);
2158 static void test_compatmode(IHTMLDocument2
*doc
)
2160 IHTMLDocument5
*doc5
;
2164 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
2165 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
2169 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
2170 IHTMLDocument5_Release(doc5
);
2171 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
2172 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", dbgstr_w(mode
));
2173 SysFreeString(mode
);
2176 static void test_location(IHTMLDocument2
*doc
)
2178 IHTMLLocation
*location
, *location2
;
2182 hres
= IHTMLDocument2_get_location(doc
, &location
);
2183 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
2185 hres
= IHTMLDocument2_get_location(doc
, &location2
);
2186 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
2188 ok(location
== location2
, "location != location2\n");
2190 test_ifaces((IUnknown
*)location
, location_iids
);
2192 IHTMLLocation_Release(location2
);
2193 ref
= IHTMLLocation_Release(location
);
2194 ok(!ref
, "location chould be destroyed here\n");
2197 static void test_navigator(IHTMLDocument2
*doc
)
2199 IHTMLWindow2
*window
;
2200 IOmNavigator
*navigator
, *navigator2
;
2205 static const WCHAR v40
[] = {'4','.','0'};
2207 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2208 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
2210 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
2211 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
2212 ok(navigator
!= NULL
, "navigator == NULL\n");
2213 test_disp((IUnknown
*)navigator
, &IID_IOmNavigator
);
2215 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
2216 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
2217 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
2219 IHTMLWindow2_Release(window
);
2220 IOmNavigator_Release(navigator2
);
2222 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
2223 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
2224 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", dbgstr_w(bstr
));
2225 SysFreeString(bstr
);
2228 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
2229 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
2230 ok(!strcmp_wa(bstr
, "Win32"), "unexpected platform %s\n", dbgstr_w(bstr
));
2231 SysFreeString(bstr
);
2234 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
2235 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
2236 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", dbgstr_w(bstr
));
2237 SysFreeString(bstr
);
2239 ref
= IOmNavigator_Release(navigator
);
2240 ok(!ref
, "navigator should be destroyed here\n");
2243 static void test_current_style(IHTMLCurrentStyle
*current_style
)
2248 test_disp((IUnknown
*)current_style
, &DIID_DispHTMLCurrentStyle
);
2249 test_ifaces((IUnknown
*)current_style
, cstyle_iids
);
2251 hres
= IHTMLCurrentStyle_get_display(current_style
, &str
);
2252 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
2253 ok(!strcmp_wa(str
, "block"), "get_display returned %s\n", dbgstr_w(str
));
2257 static void test_style2(IHTMLStyle2
*style2
)
2262 str
= (void*)0xdeadbeef;
2263 hres
= IHTMLStyle2_get_position(style2
, &str
);
2264 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
2265 ok(!str
, "str != NULL\n");
2267 str
= a2bstr("absolute");
2268 hres
= IHTMLStyle2_put_position(style2
, str
);
2269 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
2273 hres
= IHTMLStyle2_get_position(style2
, &str
);
2274 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
2275 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", dbgstr_w(str
));
2279 static void test_default_style(IHTMLStyle
*style
)
2281 IHTMLStyle2
*style2
;
2288 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
);
2289 test_ifaces((IUnknown
*)style
, style_iids
);
2291 str
= (void*)0xdeadbeef;
2292 hres
= IHTMLStyle_get_fontFamily(style
, &str
);
2293 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
2294 ok(!str
, "fontFamily = %s\n", dbgstr_w(str
));
2296 str
= (void*)0xdeadbeef;
2297 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
2298 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
2299 ok(!str
, "fontWeight = %s\n", dbgstr_w(str
));
2301 str
= (void*)0xdeadbeef;
2302 hres
= IHTMLStyle_get_display(style
, &str
);
2303 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
2304 ok(!str
, "display = %s\n", dbgstr_w(str
));
2306 str
= (void*)0xdeadbeef;
2307 hres
= IHTMLStyle_get_visibility(style
, &str
);
2308 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
2309 ok(!str
, "visibility = %s\n", dbgstr_w(str
));
2312 hres
= IHTMLStyle_get_fontSize(style
, &v
);
2313 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
2314 ok(V_VT(&v
) == VT_BSTR
, "V_VT(fontSize) = %d\n", V_VT(&v
));
2315 ok(!V_BSTR(&v
), "V_BSTR(fontSize) = %s\n", dbgstr_w(V_BSTR(&v
)));
2318 hres
= IHTMLStyle_get_color(style
, &v
);
2319 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
2320 ok(V_VT(&v
) == VT_BSTR
, "V_VT(color) = %d\n", V_VT(&v
));
2321 ok(!V_BSTR(&v
), "V_BSTR(color) = %s\n", dbgstr_w(V_BSTR(&v
)));
2324 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
2325 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
2326 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
2329 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
2330 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
2331 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
2333 V_VT(&v
) = VT_EMPTY
;
2334 hres
= IHTMLStyle_get_width(style
, &v
);
2335 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
2336 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2337 ok(!V_BSTR(&v
), "V_BSTR(v)=%p\n", V_BSTR(&v
));
2340 V_BSTR(&v
) = a2bstr("auto");
2341 hres
= IHTMLStyle_put_width(style
, v
);
2342 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
2345 V_VT(&v
) = VT_EMPTY
;
2346 hres
= IHTMLStyle_get_width(style
, &v
);
2347 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
2348 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2349 ok(!strcmp_wa(V_BSTR(&v
), "auto"), "V_BSTR(v)=%s\n", dbgstr_w(V_BSTR(&v
)));
2353 str
= (void*)0xdeadbeef;
2354 hres
= IHTMLStyle_get_margin(style
, &str
);
2355 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
2356 ok(!str
, "margin = %s\n", dbgstr_w(str
));
2359 hres
= IHTMLStyle_put_margin(style
, str
);
2360 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
2363 hres
= IHTMLStyle_get_margin(style
, &str
);
2364 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
2365 ok(strcmp_wa(str
, "1"), "margin = %s\n", dbgstr_w(str
));
2367 hres
= IHTMLStyle_put_margin(style
, NULL
);
2368 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
2371 hres
= IHTMLStyle_get_border(style
, &str
);
2372 ok(hres
== S_OK
, "get_border failed: %08x\n", hres
);
2373 ok(!str
|| !*str
, "str is not empty\n");
2376 str
= a2bstr("1px");
2377 hres
= IHTMLStyle_put_border(style
, str
);
2378 ok(hres
== S_OK
, "get_border failed: %08x\n", hres
);
2381 V_VT(&v
) = VT_EMPTY
;
2382 hres
= IHTMLStyle_get_left(style
, &v
);
2383 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2384 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2385 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2389 hres
= IHTMLStyle_get_posLeft(style
, NULL
);
2390 ok(hres
== E_POINTER
, "get_left failed: %08x\n", hres
);
2393 hres
= IHTMLStyle_get_posLeft(style
, &f
);
2394 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2395 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
2397 hres
= IHTMLStyle_put_posLeft(style
, 4.9f
);
2398 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2400 hres
= IHTMLStyle_get_posLeft(style
, &f
);
2401 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2402 ok(f
== 4.0, "expected 4.0 got %f\n", f
);
2404 /* Ensure left is updated correctly. */
2405 V_VT(&v
) = VT_EMPTY
;
2406 hres
= IHTMLStyle_get_left(style
, &v
);
2407 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2408 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2409 ok(!strcmp_wa(V_BSTR(&v
), "4px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v
)));
2414 V_BSTR(&v
) = a2bstr("3px");
2415 hres
= IHTMLStyle_put_left(style
, v
);
2416 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
2419 hres
= IHTMLStyle_get_posLeft(style
, &f
);
2420 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2421 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
2423 V_VT(&v
) = VT_EMPTY
;
2424 hres
= IHTMLStyle_get_left(style
, &v
);
2425 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2426 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2427 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v
)));
2431 hres
= IHTMLStyle_put_left(style
, v
);
2432 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
2434 V_VT(&v
) = VT_EMPTY
;
2435 hres
= IHTMLStyle_get_left(style
, &v
);
2436 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2437 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2438 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2441 V_VT(&v
) = VT_EMPTY
;
2442 hres
= IHTMLStyle_get_top(style
, &v
);
2443 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
2444 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2445 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2449 hres
= IHTMLStyle_get_posTop(style
, NULL
);
2450 ok(hres
== E_POINTER
, "get_left failed: %08x\n", hres
);
2453 hres
= IHTMLStyle_get_posTop(style
, &f
);
2454 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2455 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
2457 hres
= IHTMLStyle_put_posTop(style
, 4.9f
);
2458 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2460 hres
= IHTMLStyle_get_posTop(style
, &f
);
2461 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2462 ok(f
== 4.0, "expected 4.0 got %f\n", f
);
2465 V_BSTR(&v
) = a2bstr("3px");
2466 hres
= IHTMLStyle_put_top(style
, v
);
2467 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
2470 V_VT(&v
) = VT_EMPTY
;
2471 hres
= IHTMLStyle_get_top(style
, &v
);
2472 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
2473 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2474 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v
)));
2477 hres
= IHTMLStyle_get_posTop(style
, &f
);
2478 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2479 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
2482 hres
= IHTMLStyle_put_top(style
, v
);
2483 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
2485 V_VT(&v
) = VT_EMPTY
;
2486 hres
= IHTMLStyle_get_top(style
, &v
);
2487 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
2488 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2489 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2492 V_VT(&v
) = VT_EMPTY
;
2493 hres
= IHTMLStyle_get_height(style
, &v
);
2494 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
2495 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2496 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2500 V_BSTR(&v
) = a2bstr("64px");
2501 hres
= IHTMLStyle_put_height(style
, v
);
2502 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
2505 V_VT(&v
) = VT_EMPTY
;
2506 hres
= IHTMLStyle_get_height(style
, &v
);
2507 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
2508 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2509 ok(!strcmp_wa(V_BSTR(&v
), "64px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v
)));
2512 str
= (void*)0xdeadbeef;
2513 hres
= IHTMLStyle_get_cursor(style
, &str
);
2514 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
2515 ok(!str
, "get_cursor != NULL\n");
2518 str
= a2bstr("default");
2519 hres
= IHTMLStyle_put_cursor(style
, str
);
2520 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
2524 hres
= IHTMLStyle_get_cursor(style
, &str
);
2525 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
2526 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", dbgstr_w(str
));
2529 V_VT(&v
) = VT_EMPTY
;
2530 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
2531 ok(hres
== S_OK
, "get_vertivalAlign failed: %08x\n", hres
);
2532 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2533 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2537 V_BSTR(&v
) = a2bstr("middle");
2538 hres
= IHTMLStyle_put_verticalAlign(style
, v
);
2539 ok(hres
== S_OK
, "put_vertivalAlign failed: %08x\n", hres
);
2542 V_VT(&v
) = VT_EMPTY
;
2543 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
2544 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
2545 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2546 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v
)));
2549 str
= (void*)0xdeadbeef;
2550 hres
= IHTMLStyle_get_textAlign(style
, &str
);
2551 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
2552 ok(!str
, "textAlign != NULL\n");
2554 str
= a2bstr("center");
2555 hres
= IHTMLStyle_put_textAlign(style
, str
);
2556 ok(hres
== S_OK
, "put_textAlign failed: %08x\n", hres
);
2560 hres
= IHTMLStyle_get_textAlign(style
, &str
);
2561 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
2562 ok(!strcmp_wa(str
, "center"), "textAlign = %s\n", dbgstr_w(V_BSTR(&v
)));
2565 str
= (void*)0xdeadbeef;
2566 hres
= IHTMLStyle_get_filter(style
, &str
);
2567 ok(hres
== S_OK
, "get_filter failed: %08x\n", hres
);
2568 ok(!str
, "filter != NULL\n");
2570 str
= a2bstr("alpha(opacity=100)");
2571 hres
= IHTMLStyle_put_filter(style
, str
);
2572 ok(hres
== S_OK
, "put_filter failed: %08x\n", hres
);
2575 V_VT(&v
) = VT_EMPTY
;
2576 hres
= IHTMLStyle_get_zIndex(style
, &v
);
2577 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
2578 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
2579 ok(!V_I4(&v
), "V_I4(v) != 0\n");
2583 V_BSTR(&v
) = a2bstr("1");
2584 hres
= IHTMLStyle_put_zIndex(style
, v
);
2585 ok(hres
== S_OK
, "put_zIndex failed: %08x\n", hres
);
2588 V_VT(&v
) = VT_EMPTY
;
2589 hres
= IHTMLStyle_get_zIndex(style
, &v
);
2590 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
2591 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
2592 ok(V_I4(&v
) == 1, "V_I4(v) = %d\n", V_I4(&v
));
2595 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle2
, (void**)&style2
);
2596 ok(hres
== S_OK
, "Could not get IHTMLStyle2 iface: %08x\n", hres
);
2597 if(SUCCEEDED(hres
)) {
2598 test_style2(style2
);
2599 IHTMLStyle2_Release(style2
);
2603 static void test_default_selection(IHTMLDocument2
*doc
)
2605 IHTMLSelectionObject
*selection
;
2606 IHTMLTxtRange
*range
;
2611 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
2612 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
2614 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
2615 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
2616 ok(!lstrcmpW(str
, noneW
), "type = %s\n", dbgstr_w(str
));
2619 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
2620 IHTMLSelectionObject_Release(selection
);
2621 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
2623 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
2624 IDispatch_Release(disp
);
2625 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
2627 test_range_text(range
, NULL
);
2628 IHTMLTxtRange_Release(range
);
2631 static void test_default_body(IHTMLBodyElement
*body
)
2637 WCHAR sBodyText
[] = {'#','F','F','0','0','0','0',0};
2638 WCHAR sTextInvalid
[] = {'I','n','v','a','l','i','d',0};
2639 WCHAR sResInvalid
[] = {'#','0','0','a','0','d','0',0};
2641 bstr
= (void*)0xdeadbeef;
2642 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
2643 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
2644 ok(bstr
== NULL
, "bstr != NULL\n");
2646 l
= elem_get_scroll_height((IUnknown
*)body
);
2647 ok(l
!= -1, "scrollHeight == -1\n");
2648 l
= elem_get_scroll_width((IUnknown
*)body
);
2649 ok(l
!= -1, "scrollWidth == -1\n");
2650 l
= elem_get_scroll_top((IUnknown
*)body
);
2651 ok(!l
, "scrollTop = %ld\n", l
);
2652 elem_get_scroll_left((IUnknown
*)body
);
2654 /* get_text tests */
2655 hres
= IHTMLBodyElement_get_text(body
, &v
);
2656 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
2657 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
2658 ok(bstr
== NULL
, "bstr != NULL\n");
2661 /* get_text - Invalid Text */
2663 V_BSTR(&v
) = SysAllocString(sTextInvalid
);
2664 hres
= IHTMLBodyElement_put_text(body
, v
);
2665 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
2668 hres
= IHTMLBodyElement_get_text(body
, &v
);
2669 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
2670 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
2671 ok(!lstrcmpW(sResInvalid
, V_BSTR(&v
)), "bstr != sResInvalid\n");
2674 /* get_text - Valid Text */
2676 V_BSTR(&v
) = SysAllocString(sBodyText
);
2677 hres
= IHTMLBodyElement_put_text(body
, v
);
2678 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
2681 hres
= IHTMLBodyElement_get_text(body
, &v
);
2682 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
2683 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
2684 ok(lstrcmpW(bstr
, V_BSTR(&v
)), "bstr != V_BSTR(&v)\n");
2688 static void test_body_funs(IHTMLBodyElement
*body
)
2690 static WCHAR sRed
[] = {'r','e','d',0};
2691 static WCHAR sRedbg
[] = {'#','f','f','0','0','0','0',0};
2696 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
2697 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
2698 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
2700 V_VT(&vbg
) = VT_BSTR
;
2701 V_BSTR(&vbg
) = SysAllocString(sRed
);
2702 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
2703 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
2706 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
2707 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
2708 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "V_VT(&vDefaultbg) != VT_BSTR\n");
2709 ok(!lstrcmpW(V_BSTR(&vbg
), sRedbg
), "Unexpected type %s\n", dbgstr_w(V_BSTR(&vbg
)));
2712 /* Restore Originial */
2713 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
2714 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
2715 VariantClear(&vDefaultbg
);
2718 static void test_window(IHTMLDocument2
*doc
)
2720 IHTMLWindow2
*window
, *window2
, *self
;
2721 IHTMLDocument2
*doc2
= NULL
;
2725 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2726 ok(hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2727 test_ifaces((IUnknown
*)window
, window_iids
);
2728 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
);
2730 hres
= IHTMLWindow2_get_document(window
, &doc2
);
2731 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2732 ok(doc2
!= NULL
, "doc2 == NULL\n");
2734 IHTMLDocument_Release(doc2
);
2736 hres
= IHTMLWindow2_get_window(window
, &window2
);
2737 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
2738 ok(window2
!= NULL
, "window2 == NULL\n");
2740 hres
= IHTMLWindow2_get_self(window
, &self
);
2741 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
2742 ok(window2
!= NULL
, "self == NULL\n");
2744 ok(self
== window2
, "self != window2\n");
2746 IHTMLWindow2_Release(window2
);
2747 IHTMLWindow2_Release(self
);
2750 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
2751 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
2752 ok(disp
== (void*)window
, "disp != window\n");
2753 IDispatch_Release(disp
);
2755 IHTMLWindow2_Release(window
);
2758 static void test_defaults(IHTMLDocument2
*doc
)
2760 IHTMLStyleSheetsCollection
*stylesheetcol
;
2761 IHTMLCurrentStyle
*cstyle
;
2762 IHTMLBodyElement
*body
;
2763 IHTMLElement2
*elem2
;
2768 IHTMLElementCollection
*colimages
;
2770 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2771 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2773 hres
= IHTMLDocument2_get_images(doc
, NULL
);
2774 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
2776 hres
= IHTMLDocument2_get_images(doc
, &colimages
);
2777 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
2780 test_elem_collection((IUnknown
*)colimages
, NULL
, 0);
2781 IHTMLElementCollection_Release(colimages
);
2784 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
2785 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
2786 test_default_body(body
);
2787 test_body_funs(body
);
2788 IHTMLBodyElement_Release(body
);
2790 hres
= IHTMLElement_get_style(elem
, &style
);
2791 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
2793 test_default_style(style
);
2795 test_compatmode(doc
);
2797 test_navigator(doc
);
2799 IHTMLStyle_Release(style
);
2801 elem2
= get_elem2_iface((IUnknown
*)elem
);
2802 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
2803 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
2804 if(SUCCEEDED(hres
)) {
2805 test_current_style(cstyle
);
2806 IHTMLCurrentStyle_Release(cstyle
);
2808 IHTMLElement2_Release(elem2
);
2810 IHTMLElement_Release(elem
);
2812 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
2813 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
2816 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
2817 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2818 ok(l
== 0, "length = %ld\n", l
);
2820 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
2822 test_default_selection(doc
);
2823 test_doc_title(doc
, "");
2826 static void test_tr_elem(IHTMLElement
*elem
)
2828 IHTMLElementCollection
*col
;
2832 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
2834 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
2835 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
2840 hres
= IHTMLTableRow_get_cells(row
, &col
);
2841 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
2842 ok(col
!= NULL
, "get_cells returned NULL\n");
2844 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
2845 IHTMLElementCollection_Release(col
);
2847 IHTMLTable_Release(row
);
2850 static void test_table_elem(IHTMLElement
*elem
)
2852 IHTMLElementCollection
*col
;
2856 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
2858 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
2859 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
2864 hres
= IHTMLTable_get_rows(table
, &col
);
2865 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
2866 ok(col
!= NULL
, "get_ros returned NULL\n");
2868 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
2869 IHTMLElementCollection_Release(col
);
2871 IHTMLTable_Release(table
);
2874 static void doc_write(IHTMLDocument2
*doc
, const char *text
)
2884 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
2885 SafeArrayAccessData(sa
, (void**)&var
);
2886 V_VT(var
) = VT_BSTR
;
2887 V_BSTR(var
) = str
= a2bstr(text
);
2888 SafeArrayUnaccessData(sa
);
2890 hres
= IHTMLDocument2_write(doc
, sa
);
2891 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
2894 SafeArrayDestroy(sa
);
2897 static void test_iframe_elem(IHTMLElement
*elem
)
2899 IHTMLElementCollection
*col
;
2900 IHTMLDocument2
*content_doc
;
2901 IHTMLWindow2
*content_window
;
2902 IHTMLFrameBase2
*base2
;
2908 static const elem_type_t all_types
[] = {
2916 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
2917 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
2920 content_window
= NULL
;
2921 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &content_window
);
2922 IHTMLFrameBase2_Release(base2
);
2923 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
2924 ok(content_window
!= NULL
, "contentWindow = NULL\n");
2927 hres
= IHTMLWindow2_get_document(content_window
, &content_doc
);
2928 IHTMLWindow2_Release(content_window
);
2929 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2930 ok(content_doc
!= NULL
, "content_doc = NULL\n");
2932 str
= a2bstr("text/html");
2933 V_VT(&errv
) = VT_ERROR
;
2935 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
2937 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
2938 ok(disp
!= NULL
, "disp == NULL\n");
2939 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
2940 IDispatch_Release(disp
);
2942 doc_write(content_doc
, "<html><head><title>test</title></head><body><br /></body></html>");
2944 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
2945 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2946 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
2947 IHTMLElementCollection_Release(col
);
2949 hres
= IHTMLDocument2_close(content_doc
);
2950 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
2952 IHTMLDocument2_Release(content_doc
);
2955 static void test_stylesheet(IDispatch
*disp
)
2957 IHTMLStyleSheetRulesCollection
*col
= NULL
;
2958 IHTMLStyleSheet
*stylesheet
;
2961 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
2962 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
2964 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
2965 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
2966 ok(col
!= NULL
, "col == NULL\n");
2968 IHTMLStyleSheetRulesCollection_Release(col
);
2969 IHTMLStyleSheet_Release(stylesheet
);
2972 static void test_stylesheets(IHTMLDocument2
*doc
)
2974 IHTMLStyleSheetsCollection
*col
= NULL
;
2979 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
2980 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
2981 ok(col
!= NULL
, "col == NULL\n");
2983 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
2984 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2985 ok(len
== 1, "len=%ld\n", len
);
2991 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
2992 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2993 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
2994 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
2995 test_stylesheet(V_DISPATCH(&res
));
3002 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
3003 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3004 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
3005 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
3008 IHTMLStyleSheetsCollection_Release(col
);
3011 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
3013 IDispatchEx
*dispex
;
3015 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3023 static const WCHAR w0
[] = {'0',0};
3024 static const WCHAR w100
[] = {'1','0','0',0};
3026 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
3027 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
3029 bstr
= SysAllocString(w0
);
3030 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3031 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3032 SysFreeString(bstr
);
3035 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3036 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3037 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3038 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3039 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
3040 type
= get_node_type((IUnknown
*)node
);
3041 ok(type
== 3, "type=%ld\n", type
);
3042 IHTMLDOMNode_Release(node
);
3045 bstr
= SysAllocString(w100
);
3046 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3047 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
3048 SysFreeString(bstr
);
3050 IDispatchEx_Release(dispex
);
3055 static void test_elems(IHTMLDocument2
*doc
)
3057 IHTMLElementCollection
*col
;
3058 IHTMLDOMChildrenCollection
*child_col
;
3059 IHTMLElement
*elem
, *elem2
, *elem3
;
3060 IHTMLDOMNode
*node
, *node2
;
3064 IHTMLElementCollection
*colimages
;
3066 static const WCHAR imgidW
[] = {'i','m','g','i','d',0};
3067 static const WCHAR inW
[] = {'i','n',0};
3068 static const WCHAR xW
[] = {'x',0};
3069 static const WCHAR sW
[] = {'s',0};
3070 static const WCHAR scW
[] = {'s','c',0};
3071 static const WCHAR xxxW
[] = {'x','x','x',0};
3072 static const WCHAR tblW
[] = {'t','b','l',0};
3073 static const WCHAR row2W
[] = {'r','o','w','2',0};
3074 static const WCHAR ifrW
[] = {'i','f','r',0};
3076 static const elem_type_t all_types
[] = {
3101 static const elem_type_t item_types
[] = {
3107 hres
= IHTMLDocument2_get_all(doc
, &col
);
3108 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3109 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
3110 test_elem_col_item(col
, xW
, item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
3111 IHTMLElementCollection_Release(col
);
3113 hres
= IHTMLDocument2_get_images(doc
, &colimages
);
3114 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
3117 static const elem_type_t images_types
[] = {ET_IMG
};
3118 test_elem_collection((IUnknown
*)colimages
, images_types
, 1);
3120 IHTMLElementCollection_Release(colimages
);
3123 elem
= get_doc_elem(doc
);
3124 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
3125 hres
= IHTMLElement_get_all(elem
, &disp
);
3126 IHTMLElement_Release(elem
);
3127 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3129 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLElementCollection
, (void**)&col
);
3130 IDispatch_Release(disp
);
3131 ok(hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
3132 test_elem_collection((IUnknown
*)col
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
3133 IHTMLElementCollection_Release(col
);
3135 get_elem_by_id(doc
, xxxW
, FALSE
);
3136 elem
= get_doc_elem_by_id(doc
, xxxW
);
3137 ok(!elem
, "elem != NULL\n");
3139 elem
= get_doc_elem_by_id(doc
, sW
);
3140 ok(elem
!= NULL
, "elem == NULL\n");
3142 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
3143 test_elem_attr(elem
, xxxW
, NULL
);
3144 test_elem_attr(elem
, idW
, sW
);
3145 test_elem_class((IUnknown
*)elem
, NULL
);
3146 test_elem_set_class((IUnknown
*)elem
, "cl");
3147 test_elem_set_class((IUnknown
*)elem
, NULL
);
3148 test_elem_tabindex((IUnknown
*)elem
, 0);
3149 test_elem_set_tabindex((IUnknown
*)elem
, 1);
3151 node
= test_node_get_parent((IUnknown
*)elem
);
3152 ok(node
!= NULL
, "node == NULL\n");
3153 test_node_name((IUnknown
*)node
, "BODY");
3154 node2
= test_node_get_parent((IUnknown
*)node
);
3155 IHTMLDOMNode_Release(node
);
3156 ok(node2
!= NULL
, "node == NULL\n");
3157 test_node_name((IUnknown
*)node2
, "HTML");
3158 node
= test_node_get_parent((IUnknown
*)node2
);
3159 IHTMLDOMNode_Release(node2
);
3160 ok(node
!= NULL
, "node == NULL\n");
3163 test_node_name((IUnknown
*)node
, "#document");
3164 type
= get_node_type((IUnknown
*)node
);
3165 ok(type
== 9, "type=%ld, expected 9\n", type
);
3166 node2
= test_node_get_parent((IUnknown
*)node
);
3167 IHTMLDOMNode_Release(node
);
3168 ok(node2
== NULL
, "node != NULL\n");
3171 elem2
= test_elem_get_parent((IUnknown
*)elem
);
3172 ok(elem2
!= NULL
, "elem2 == NULL\n");
3173 test_node_name((IUnknown
*)elem2
, "BODY");
3174 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
3175 IHTMLElement_Release(elem2
);
3176 ok(elem3
!= NULL
, "elem3 == NULL\n");
3177 test_node_name((IUnknown
*)elem3
, "HTML");
3178 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
3179 IHTMLElement_Release(elem3
);
3180 ok(elem2
== NULL
, "elem2 != NULL\n");
3182 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2);
3183 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0);
3184 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0);
3186 test_elem_innertext(elem
, "opt1opt2");
3188 IHTMLElement_Release(elem
);
3191 elem
= get_elem_by_id(doc
, sW
, TRUE
);
3193 IHTMLSelectElement
*select
;
3195 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLSelectElement
, (void**)&select
);
3196 ok(hres
== S_OK
, "Could not get IHTMLSelectElement interface: %08x\n", hres
);
3198 test_select_elem(select
);
3200 test_elem_title((IUnknown
*)select
, NULL
);
3201 test_elem_set_title((IUnknown
*)select
, "Title");
3202 test_elem_title((IUnknown
*)select
, "Title");
3203 test_elem_offset((IUnknown
*)select
);
3205 node
= get_first_child((IUnknown
*)select
);
3206 ok(node
!= NULL
, "node == NULL\n");
3208 test_elem_type((IUnknown
*)node
, ET_OPTION
);
3209 IHTMLDOMNode_Release(node
);
3212 type
= get_node_type((IUnknown
*)select
);
3213 ok(type
== 1, "type=%ld\n", type
);
3215 IHTMLSelectElement_Release(select
);
3216 IHTMLElement_Release(elem
);
3219 elem
= get_elem_by_id(doc
, scW
, TRUE
);
3221 IHTMLScriptElement
*script
;
3224 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
3225 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
3227 hres
= IHTMLScriptElement_get_type(script
, &type
);
3228 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
3229 ok(!lstrcmpW(type
, text_javascriptW
), "Unexpected type %s\n", dbgstr_w(type
));
3230 SysFreeString(type
);
3232 IHTMLScriptElement_Release(script
);
3235 elem
= get_elem_by_id(doc
, inW
, TRUE
);
3237 IHTMLInputElement
*input
;
3239 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
3240 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3242 test_elem_id((IUnknown
*)elem
, "in");
3243 test_elem_put_id((IUnknown
*)elem
, "newin");
3244 test_input_get_disabled(input
, VARIANT_FALSE
);
3245 test_input_set_disabled(input
, VARIANT_TRUE
);
3246 test_input_set_disabled(input
, VARIANT_FALSE
);
3247 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
3248 test_input_get_disabled(input
, VARIANT_TRUE
);
3249 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
3250 test_input_get_disabled(input
, VARIANT_FALSE
);
3251 test_elem_client_size((IUnknown
*)elem
);
3253 test_node_get_value_str((IUnknown
*)elem
, NULL
);
3254 test_node_put_value_str((IUnknown
*)elem
, "test");
3255 test_node_get_value_str((IUnknown
*)elem
, NULL
);
3256 test_input_value((IUnknown
*)elem
, NULL
);
3257 test_input_put_value((IUnknown
*)elem
, "test");
3258 test_input_value((IUnknown
*)elem
, NULL
);
3259 test_elem_class((IUnknown
*)elem
, "testclass");
3260 test_elem_tabindex((IUnknown
*)elem
, 2);
3261 test_elem_set_tabindex((IUnknown
*)elem
, 3);
3262 test_elem_title((IUnknown
*)elem
, "test title");
3264 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
3265 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
3266 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
3268 test_input_get_checked(input
, VARIANT_FALSE
);
3269 test_input_set_checked(input
, VARIANT_TRUE
);
3270 test_input_set_checked(input
, VARIANT_FALSE
);
3272 IHTMLInputElement_Release(input
);
3273 IHTMLElement_Release(elem
);
3276 elem
= get_elem_by_id(doc
, imgidW
, TRUE
);
3278 test_img_src((IUnknown
*)elem
, "");
3279 test_img_set_src((IUnknown
*)elem
, "about:blank");
3280 test_img_alt((IUnknown
*)elem
, NULL
);
3281 test_img_set_alt((IUnknown
*)elem
, "alt test");
3282 IHTMLElement_Release(elem
);
3285 elem
= get_doc_elem_by_id(doc
, tblW
);
3286 ok(elem
!= NULL
, "elem == NULL\n");
3288 test_table_elem(elem
);
3289 IHTMLElement_Release(elem
);
3292 elem
= get_doc_elem_by_id(doc
, row2W
);
3293 ok(elem
!= NULL
, "elem == NULL\n");
3296 IHTMLElement_Release(elem
);
3299 elem
= get_doc_elem_by_id(doc
, ifrW
);
3300 ok(elem
!= NULL
, "elem == NULL\n");
3302 test_iframe_elem(elem
);
3303 IHTMLElement_Release(elem
);
3306 hres
= IHTMLDocument2_get_body(doc
, &elem
);
3307 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
3309 node
= get_first_child((IUnknown
*)elem
);
3310 ok(node
!= NULL
, "node == NULL\n");
3312 test_ifaces((IUnknown
*)node
, text_iids
);
3313 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
);
3315 node2
= get_first_child((IUnknown
*)node
);
3316 ok(!node2
, "node2 != NULL\n");
3318 type
= get_node_type((IUnknown
*)node
);
3319 ok(type
== 3, "type=%ld\n", type
);
3321 test_node_get_value_str((IUnknown
*)node
, "text test");
3322 test_node_put_value_str((IUnknown
*)elem
, "test text");
3323 test_node_get_value_str((IUnknown
*)node
, "text test");
3325 IHTMLDOMNode_Release(node
);
3328 child_col
= get_child_nodes((IUnknown
*)elem
);
3329 ok(child_col
!= NULL
, "child_coll == NULL\n");
3333 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
);
3335 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
3336 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3337 ok(length
, "length=0\n");
3339 node
= get_child_item(child_col
, 0);
3340 ok(node
!= NULL
, "node == NULL\n");
3342 type
= get_node_type((IUnknown
*)node
);
3343 ok(type
== 3, "type=%ld\n", type
);
3344 IHTMLDOMNode_Release(node
);
3347 node
= get_child_item(child_col
, 1);
3348 ok(node
!= NULL
, "node == NULL\n");
3350 type
= get_node_type((IUnknown
*)node
);
3351 ok(type
== 8, "type=%ld\n", type
);
3353 test_elem_id((IUnknown
*)node
, NULL
);
3354 IHTMLDOMNode_Release(node
);
3357 disp
= (void*)0xdeadbeef;
3358 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
3359 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3360 ok(disp
== (void*)0xdeadbeef, "disp=%p\n", disp
);
3362 disp
= (void*)0xdeadbeef;
3363 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
3364 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3365 ok(disp
== (void*)0xdeadbeef, "disp=%p\n", disp
);
3367 test_child_col_disp(child_col
);
3369 IHTMLDOMChildrenCollection_Release(child_col
);
3372 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
3373 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
3374 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
3376 IHTMLElement_Release(elem
);
3378 test_stylesheets(doc
);
3379 test_create_option_elem(doc
);
3381 elem
= get_doc_elem_by_id(doc
, tblW
);
3382 ok(elem
!= NULL
, "elem = NULL\n");
3383 test_elem_set_innertext(elem
, "inner text");
3384 IHTMLElement_Release(elem
);
3386 test_doc_title(doc
, "test");
3387 test_doc_set_title(doc
, "test title");
3388 test_doc_title(doc
, "test title");
3391 static void test_create_elems(IHTMLDocument2
*doc
)
3393 IHTMLElement
*elem
, *body
, *elem2
;
3394 IHTMLDOMNode
*node
, *node2
, *node3
;
3400 static const elem_type_t types1
[] = { ET_TESTG
};
3402 elem
= test_create_elem(doc
, "TEST");
3403 test_elem_tag((IUnknown
*)elem
, "TEST");
3404 type
= get_node_type((IUnknown
*)elem
);
3405 ok(type
== 1, "type=%ld\n", type
);
3406 test_ifaces((IUnknown
*)elem
, elem_iids
);
3407 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
);
3409 hres
= IHTMLDocument2_get_body(doc
, &body
);
3410 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
3411 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
3413 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
3414 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
3415 elem2
= get_elem_iface((IUnknown
*)node
);
3416 IHTMLElement_Release(elem2
);
3418 hres
= IHTMLElement_get_all(body
, &disp
);
3419 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3420 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
3421 IDispatch_Release(disp
);
3423 test_node_remove_child((IUnknown
*)body
, node
);
3425 hres
= IHTMLElement_get_all(body
, &disp
);
3426 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3427 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
3428 IDispatch_Release(disp
);
3429 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
3431 IHTMLElement_Release(elem
);
3432 IHTMLDOMNode_Release(node
);
3434 node
= test_create_text(doc
, "test");
3435 test_ifaces((IUnknown
*)node
, text_iids
);
3436 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
);
3438 V_VT(&var
) = VT_NULL
;
3439 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
3440 IHTMLDOMNode_Release(node
);
3442 node
= test_create_text(doc
, "insert ");
3444 V_VT(&var
) = VT_DISPATCH
;
3445 V_DISPATCH(&var
) = (IDispatch
*)node2
;
3446 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
3447 IHTMLDOMNode_Release(node
);
3448 IHTMLDOMNode_Release(node2
);
3449 IHTMLDOMNode_Release(node3
);
3451 test_elem_innertext(body
, "insert test");
3453 IHTMLElement_Release(body
);
3456 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
3458 IOleCommandTarget
*cmdtrg
;
3461 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
3462 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
3464 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
3465 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
3467 IOleCommandTarget_Release(cmdtrg
);
3470 static void test_indent(IHTMLDocument2
*doc
)
3472 IHTMLElementCollection
*col
;
3473 IHTMLTxtRange
*range
;
3476 static const elem_type_t all_types
[] = {
3485 static const elem_type_t indent_types
[] = {
3496 hres
= IHTMLDocument2_get_all(doc
, &col
);
3497 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3498 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
3499 IHTMLElementCollection_Release(col
);
3501 range
= test_create_body_range(doc
);
3502 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
3503 IHTMLTxtRange_Release(range
);
3505 hres
= IHTMLDocument2_get_all(doc
, &col
);
3506 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3507 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
3508 IHTMLElementCollection_Release(col
);
3511 static void test_cond_comment(IHTMLDocument2
*doc
)
3513 IHTMLElementCollection
*col
;
3516 static const elem_type_t all_types
[] = {
3524 hres
= IHTMLDocument2_get_all(doc
, &col
);
3525 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3526 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
3527 IHTMLElementCollection_Release(col
);
3530 static IHTMLDocument2
*notif_doc
;
3531 static BOOL doc_complete
;
3533 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
3534 REFIID riid
, void**ppv
)
3536 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
3541 ok(0, "unexpected call\n");
3542 return E_NOINTERFACE
;
3545 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
3550 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
3555 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
3557 if(dispID
== DISPID_READYSTATE
){
3561 static const WCHAR completeW
[] = {'c','o','m','p','l','e','t','e',0};
3563 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
3564 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
3566 if(!lstrcmpW(state
, completeW
))
3567 doc_complete
= TRUE
;
3569 SysFreeString(state
);
3575 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
3577 ok(0, "unexpected call\n");
3581 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
3582 PropertyNotifySink_QueryInterface
,
3583 PropertyNotifySink_AddRef
,
3584 PropertyNotifySink_Release
,
3585 PropertyNotifySink_OnChanged
,
3586 PropertyNotifySink_OnRequestEdit
3589 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
3591 static IHTMLDocument2
*create_doc_with_string(const char *str
)
3593 IPersistStreamInit
*init
;
3595 IHTMLDocument2
*doc
;
3599 notif_doc
= doc
= create_document();
3603 doc_complete
= FALSE
;
3605 mem
= GlobalAlloc(0, len
);
3606 memcpy(mem
, str
, len
);
3607 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
3609 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
3611 IPersistStreamInit_Load(init
, stream
);
3612 IPersistStreamInit_Release(init
);
3613 IStream_Release(stream
);
3618 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
3620 IConnectionPointContainer
*container
;
3621 IConnectionPoint
*cp
;
3625 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
3626 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
3628 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
3629 IConnectionPointContainer_Release(container
);
3630 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
3632 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
3633 IConnectionPoint_Release(cp
);
3634 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
3637 typedef void (*domtest_t
)(IHTMLDocument2
*);
3639 static void run_domtest(const char *str
, domtest_t test
)
3641 IHTMLDocument2
*doc
;
3642 IHTMLElement
*body
= NULL
;
3647 doc
= create_doc_with_string(str
);
3648 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
3650 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
3651 TranslateMessage(&msg
);
3652 DispatchMessage(&msg
);
3655 hres
= IHTMLDocument2_get_body(doc
, &body
);
3656 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
3659 IHTMLElement_Release(body
);
3662 skip("Could not get document body. Assuming no Gecko installed.\n");
3665 ref
= IHTMLDocument2_Release(doc
);
3667 ref
== 1, /* Vista */
3671 static void gecko_installer_workaround(BOOL disable
)
3676 static BOOL has_url
= FALSE
;
3677 static char url
[2048];
3679 if(!disable
&& !has_url
)
3682 res
= RegOpenKey(HKEY_CURRENT_USER
, "Software\\Wine\\MSHTML", &hkey
);
3683 if(res
!= ERROR_SUCCESS
)
3687 DWORD type
, size
= sizeof(url
);
3689 res
= RegQueryValueEx(hkey
, "GeckoUrl", NULL
, &type
, (PVOID
)url
, &size
);
3690 if(res
== ERROR_SUCCESS
&& type
== REG_SZ
)
3693 RegDeleteValue(hkey
, "GeckoUrl");
3695 RegSetValueEx(hkey
, "GeckoUrl", 0, REG_SZ
, (PVOID
)url
, lstrlenA(url
)+1);
3703 gecko_installer_workaround(TRUE
);
3706 run_domtest(doc_str1
, test_doc_elem
);
3707 run_domtest(range_test_str
, test_txtrange
);
3708 run_domtest(range_test2_str
, test_txtrange2
);
3709 run_domtest(elem_test_str
, test_elems
);
3710 run_domtest(doc_blank
, test_create_elems
);
3711 run_domtest(doc_blank
, test_defaults
);
3712 run_domtest(indent_test_str
, test_indent
);
3713 run_domtest(cond_comment_str
, test_cond_comment
);
3716 gecko_installer_workaround(FALSE
);