2 * Copyright 2007 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><tbody></tbody></table>"
49 "<script id=\"sc\" type=\"text/javascript\"></script>"
53 static const char indent_test_str
[] =
54 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
56 static const WCHAR noneW
[] = {'N','o','n','e',0};
58 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
59 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
60 static WCHAR wordW
[] = {'w','o','r','d',0};
62 static const WCHAR text_javascriptW
[] = {'t','e','x','t','/','j','a','v','a','s','c','r','i','p','t',0};
64 static const WCHAR idW
[] = {'i','d',0};
90 static REFIID
const none_iids
[] = {
95 static REFIID
const elem_iids
[] = {
101 &IID_IConnectionPointContainer
,
105 static REFIID
const body_iids
[] = {
110 &IID_IHTMLTextContainer
,
111 &IID_IHTMLBodyElement
,
113 &IID_IConnectionPointContainer
,
117 static REFIID
const anchor_iids
[] = {
122 &IID_IHTMLAnchorElement
,
124 &IID_IConnectionPointContainer
,
128 static REFIID
const input_iids
[] = {
133 &IID_IHTMLInputElement
,
134 &IID_IHTMLInputTextElement
,
136 &IID_IConnectionPointContainer
,
140 static REFIID
const select_iids
[] = {
145 &IID_IHTMLSelectElement
,
147 &IID_IConnectionPointContainer
,
151 static REFIID
const textarea_iids
[] = {
156 &IID_IHTMLTextAreaElement
,
158 &IID_IConnectionPointContainer
,
162 static REFIID
const option_iids
[] = {
167 &IID_IHTMLOptionElement
,
169 &IID_IConnectionPointContainer
,
173 static REFIID
const table_iids
[] = {
180 &IID_IConnectionPointContainer
,
184 static REFIID
const script_iids
[] = {
189 &IID_IHTMLScriptElement
,
191 &IID_IConnectionPointContainer
,
195 static REFIID
const text_iids
[] = {
198 &IID_IHTMLDOMTextNode
,
202 static REFIID
const location_iids
[] = {
208 static REFIID
const window_iids
[] = {
216 static REFIID
const comment_iids
[] = {
221 &IID_IHTMLCommentElement
,
223 &IID_IConnectionPointContainer
,
227 static REFIID
const img_iids
[] = {
233 &IID_IHTMLImgElement
,
234 &IID_IConnectionPointContainer
,
238 static REFIID
const generic_iids
[] = {
243 &IID_IHTMLGenericElement
,
245 &IID_IConnectionPointContainer
,
255 static const elem_type_info_t elem_type_infos
[] = {
256 {"", none_iids
, NULL
},
257 {"HTML", elem_iids
, NULL
},
258 {"HEAD", elem_iids
, NULL
},
259 {"TITLE", elem_iids
, NULL
},
260 {"BODY", body_iids
, NULL
},
261 {"A", anchor_iids
, NULL
},
262 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
263 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
264 {"TEXTAREA", textarea_iids
, NULL
},
265 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
266 {"STYLE", elem_iids
, NULL
},
267 {"BLOCKQUOTE",elem_iids
, NULL
},
268 {"P", elem_iids
, NULL
},
269 {"BR", elem_iids
, NULL
},
270 {"TABLE", table_iids
, NULL
},
271 {"TBODY", elem_iids
, NULL
},
272 {"SCRIPT", script_iids
, NULL
},
273 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
274 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
275 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
276 {"IMG", img_iids
, &DIID_DispHTMLImg
}
279 static const char *dbgstr_w(LPCWSTR str
)
281 static char buf
[512];
284 WideCharToMultiByte(CP_ACP
, 0, str
, -1, buf
, sizeof(buf
), NULL
, NULL
);
288 static const char *dbgstr_guid(REFIID riid
)
292 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
293 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
294 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
295 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
300 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
303 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
304 return lstrcmpW(strw
, buf
);
307 static BSTR
a2bstr(const char *str
)
312 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
313 ret
= SysAllocStringLen(NULL
, len
);
314 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
319 static IHTMLDocument2
*create_document(void)
324 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
325 &IID_IHTMLDocument2
, (void**)&doc
);
326 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
331 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
332 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
334 const IID
* const *piid
;
338 for(piid
= iids
; *piid
; piid
++) {
339 hres
= IDispatch_QueryInterface(iface
, *piid
, (void**)&unk
);
340 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", dbgstr_guid(*piid
), hres
);
342 IUnknown_Release(unk
);
346 #define test_disp(u,id) _test_disp(__LINE__,u,id)
347 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
)
354 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
355 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatch: %08x\n", hres
);
360 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
361 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
362 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
364 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
365 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
367 if(SUCCEEDED(hres
)) {
370 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
371 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
372 ok_(__FILE__
,line
) (IsEqualGUID(&type_attr
->guid
, diid
), "unexpected guid %s\n", dbgstr_guid(&type_attr
->guid
));
374 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
375 ITypeInfo_Release(typeinfo
);
378 IDispatchEx_Release(dispex
);
381 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
382 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
387 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
388 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLElement: %08x\n", hres
);
392 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
393 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
398 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
399 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLElement2: %08x\n", hres
);
403 #define get_node_iface(u) _get_node_iface(__LINE__,u)
404 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
409 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
410 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLDOMNode: %08x\n", hres
);
414 #define get_img_iface(u) _get_img_iface(__LINE__,u)
415 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
417 IHTMLImgElement
*img
;
420 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
421 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
425 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
426 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
428 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
432 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
433 IHTMLDOMNode_Release(node
);
434 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
435 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", dbgstr_w(name
), exname
);
440 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
441 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
443 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
447 hres
= IHTMLElement_get_tagName(elem
, &tag
);
448 IHTMLElement_Release(elem
);
449 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
450 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", dbgstr_w(tag
), extag
);
455 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
456 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
458 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
459 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
461 if(elem_type_infos
[type
].dispiid
)
462 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
);
465 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
466 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, LPCWSTR name
, LPCWSTR exval
)
474 tmp
= SysAllocString(name
);
475 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
477 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
480 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
481 ok_(__FILE__
,line
) (!lstrcmpW(exval
, V_BSTR(&value
)), "unexpected value %s\n", dbgstr_w(V_BSTR(&value
)));
483 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
486 VariantClear(&value
);
489 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
490 static void _test_elem_offset(unsigned line
, IUnknown
*unk
)
492 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
496 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
497 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
499 IHTMLElement_Release(elem
);
502 static void test_doc_elem(IHTMLDocument2
*doc
)
505 IHTMLDocument3
*doc3
;
508 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
509 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
511 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
512 IHTMLDocument3_Release(doc3
);
513 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
515 test_node_name((IUnknown
*)elem
, "HTML");
516 test_elem_tag((IUnknown
*)elem
, "HTML");
518 IHTMLElement_Release(elem
);
521 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
522 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
525 IHTMLDocument3
*doc3
;
528 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
529 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
530 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
531 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
532 IHTMLDocument3_Release(doc3
);
537 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
538 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
543 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
544 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
545 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", dbgstr_w(bstr
));
549 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
550 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
556 hres
= IHTMLOptionElement_put_text(option
, bstr
);
558 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
560 _test_option_text(line
, option
, text
);
563 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
564 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
569 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
570 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
571 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", dbgstr_w(bstr
));
575 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
576 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
581 bstr
= a2bstr(value
);
582 hres
= IHTMLOptionElement_put_value(option
, bstr
);
584 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
586 _test_option_value(line
, option
, value
);
589 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
590 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
591 const char *txt
, const char *val
)
593 IHTMLOptionElementFactory
*factory
;
594 IHTMLOptionElement
*option
;
595 IHTMLWindow2
*window
;
596 VARIANT text
, value
, empty
;
599 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
600 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
602 hres
= IHTMLWindow2_get_Option(window
, &factory
);
603 IHTMLWindow2_Release(window
);
604 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
606 V_VT(&text
) = VT_BSTR
;
607 V_BSTR(&text
) = a2bstr(txt
);
608 V_VT(&value
) = VT_BSTR
;
609 V_BSTR(&value
) = a2bstr(val
);
610 V_VT(&empty
) = VT_EMPTY
;
612 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
613 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
615 IHTMLOptionElementFactory_Release(factory
);
617 VariantClear(&value
);
619 _test_option_text(line
, option
, txt
);
620 _test_option_value(line
, option
, val
);
625 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
626 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, long length
)
628 long len
= 0xdeadbeef;
631 hres
= IHTMLSelectElement_get_length(select
, &len
);
632 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
633 ok_(__FILE__
,line
) (len
== length
, "len=%ld, expected %ld\n", len
, length
);
636 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
637 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, long index
)
639 long idx
= 0xdeadbeef;
642 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
643 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
644 ok_(__FILE__
,line
) (idx
== index
, "idx=%ld, expected %ld\n", idx
, index
);
647 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
648 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, long index
)
652 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
653 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
654 _test_select_selidx(line
, select
, index
);
657 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
658 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
663 hres
= IHTMLSelectElement_get_value(select
, &val
);
664 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
666 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", dbgstr_w(val
));
668 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", dbgstr_w(val
));
671 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
672 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
678 hres
= IHTMLSelectElement_put_value(select
, bstr
);
680 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
683 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
684 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
689 hres
= IHTMLSelectElement_get_type(select
, &type
);
690 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
691 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", dbgstr_w(type
), extype
);
694 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
695 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
700 hres
= IHTMLTxtRange_get_text(range
, &text
);
701 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
704 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
705 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=\"%s\", expected \"%s\"\n", dbgstr_w(text
), extext
);
707 ok_(__FILE__
, line
) (text
== NULL
, "text=\"%s\", expected NULL\n", dbgstr_w(text
));
714 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
715 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
719 hres
= IHTMLTxtRange_collapse(range
, b
);
720 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
721 _test_range_text(line
, range
, NULL
);
724 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
725 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
726 VARIANT_BOOL exb
, const char *extext
)
728 VARIANT_BOOL b
= 0xe0e0;
731 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
732 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
733 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
734 _test_range_text(line
, range
, extext
);
737 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
738 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, long cnt
, long excnt
)
743 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
744 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
745 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
746 _test_range_text(line
, range
, NULL
);
749 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
750 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
751 LPWSTR unit
, long cnt
, long excnt
)
756 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
757 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
758 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
761 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
762 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, long cnt
, long excnt
)
767 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
768 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
769 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
772 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
773 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
776 BSTR bstr
= a2bstr(text
);
778 hres
= IHTMLTxtRange_put_text(range
, bstr
);
779 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
781 _test_range_text(line
, range
, NULL
);
784 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
785 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
791 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
792 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
793 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
796 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
797 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
803 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
804 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
805 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
808 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
809 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
810 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
813 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
814 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
818 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
819 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
824 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
825 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
827 _test_elem_type(line
, (IUnknown
*)elem
, type
);
829 IHTMLElement_Release(elem
);
832 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
833 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
834 const elem_type_t
*elem_types
, long exlen
)
836 IHTMLElementCollection
*col
;
843 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
844 ok(hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
846 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
);
848 hres
= IHTMLElementCollection_get_length(col
, &len
);
849 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
850 ok_(__FILE__
,line
) (len
== exlen
, "len=%ld, expected %ld\n", len
, exlen
);
855 V_VT(&index
) = VT_EMPTY
;
858 for(i
=0; i
<len
; i
++) {
860 disp
= (void*)0xdeadbeef;
861 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
862 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
863 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
864 if(FAILED(hres
) || !disp
)
867 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
868 IDispatch_Release(disp
);
872 disp
= (void*)0xdeadbeef;
873 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
874 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
875 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
878 disp
= (void*)0xdeadbeef;
879 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
880 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
881 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
883 IHTMLElementCollection_Release(col
);
886 #define get_first_child(n) _get_first_child(__LINE__,n)
887 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
889 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
890 IHTMLDOMNode
*child
= NULL
;
893 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
894 IHTMLDOMNode_Release(node
);
895 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
900 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
901 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
903 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
904 VARIANT_BOOL b
= 0xdead;
907 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
908 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
909 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
911 IHTMLDOMNode_Release(node
);
914 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
915 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
917 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
918 IHTMLDOMNode
*parent
;
921 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
922 IHTMLDOMNode_Release(node
);
923 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
928 #define get_node_type(n) _get_node_type(__LINE__,n)
929 static long _get_node_type(unsigned line
, IUnknown
*unk
)
931 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
935 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
936 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
938 IHTMLDOMNode_Release(node
);
943 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
944 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
946 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
951 hres
= IHTMLImgElement_put_src(img
, tmp
);
952 IHTMLImgElement_Release(img
);
954 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
957 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
958 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
960 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
964 hres
= IHTMLImgElement_get_alt(img
, &alt
);
965 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
967 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", dbgstr_w(alt
));
969 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
973 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
974 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
976 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
981 hres
= IHTMLImgElement_put_alt(img
, tmp
);
982 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
985 _test_img_alt(line
, unk
, alt
);
988 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
989 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
991 VARIANT_BOOL disabled
= 100;
994 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
995 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
996 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
999 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1000 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
1004 hres
= IHTMLInputElement_put_disabled(input
, b
);
1005 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1007 _test_input_get_disabled(line
, input
, b
);
1010 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1011 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1013 IHTMLInputElement
*input
;
1017 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
1018 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
1022 hres
= IHTMLInputElement_get_value(input
, &bstr
);
1023 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1025 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", dbgstr_w(bstr
));
1027 ok_(__FILE__
,line
) (!exval
, "exval != NULL\n");
1028 SysFreeString(bstr
);
1029 IHTMLInputElement_Release(input
);
1032 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1033 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
1035 IHTMLInputElement
*input
;
1039 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
1040 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
1045 hres
= IHTMLInputElement_get_value(input
, &bstr
);
1046 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1047 SysFreeString(bstr
);
1048 IHTMLInputElement_Release(input
);
1051 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1052 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1054 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1055 IHTMLDOMChildrenCollection
*col
= NULL
;
1059 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1060 IHTMLDOMNode_Release(node
);
1061 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1065 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1066 IDispatch_Release(disp
);
1067 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1072 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1073 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
1075 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1076 BSTR
class = (void*)0xdeadbeef;
1079 hres
= IHTMLElement_get_className(elem
, &class);
1080 IHTMLElement_Release(elem
);
1081 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
1083 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", dbgstr_w(class));
1085 ok_(__FILE__
,line
) (!class, "class != NULL\n");
1086 SysFreeString(class);
1089 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1090 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
1092 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
1096 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
1097 IHTMLElement2_Release(elem2
);
1098 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
1099 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
1102 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1103 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
1105 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
1108 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
1109 IHTMLElement2_Release(elem2
);
1110 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
1112 _test_elem_tabindex(line
, unk
, index
);
1115 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1116 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
1118 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1122 tmp
= class ? a2bstr(class) : NULL
;
1123 hres
= IHTMLElement_put_className(elem
, tmp
);
1124 IHTMLElement_Release(elem
);
1125 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
1128 _test_elem_class(line
, unk
, class);
1131 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1132 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, long idx
)
1134 IHTMLDOMNode
*node
= NULL
;
1138 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1139 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1141 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1142 IDispatch_Release(disp
);
1147 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1148 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
1150 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1151 BSTR id
= (void*)0xdeadbeef;
1154 hres
= IHTMLElement_get_id(elem
, &id
);
1155 IHTMLElement_Release(elem
);
1156 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
1159 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", dbgstr_w(id
));
1161 ok_(__FILE__
,line
) (!id
, "id=%s\n", dbgstr_w(id
));
1166 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1167 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
1169 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1170 BSTR tmp
= a2bstr(new_id
);
1173 hres
= IHTMLElement_put_id(elem
, tmp
);
1174 IHTMLElement_Release(elem
);
1176 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
1178 _test_elem_id(line
, unk
, new_id
);
1181 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1182 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
1184 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1188 hres
= IHTMLElement_get_title(elem
, &title
);
1189 IHTMLElement_Release(elem
);
1190 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
1192 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", dbgstr_w(title
));
1194 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", dbgstr_w(title
));
1196 SysFreeString(title
);
1199 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1200 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
1202 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1206 tmp
= a2bstr(title
);
1207 hres
= IHTMLElement_put_title(elem
, tmp
);
1208 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
1210 IHTMLElement_Release(elem
);
1214 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1215 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
1217 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1221 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
1222 IHTMLDOMNode_Release(node
);
1223 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
1226 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
1227 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", dbgstr_w(V_BSTR(&var
)));
1229 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
1235 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
1236 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
1238 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1242 V_VT(&var
) = VT_BSTR
;
1243 V_BSTR(&var
) = a2bstr(val
);
1245 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
1246 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
1247 IHTMLDOMNode_Release(node
);
1251 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
1252 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
1254 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1258 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
1259 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
1260 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
1261 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
1263 IHTMLElement2_Release(elem
);
1266 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
1267 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
1269 IHTMLElement
*elem
= NULL
;
1274 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
1275 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
1276 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
1281 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
1282 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
1284 IHTMLDocument3
*doc3
;
1285 IHTMLDOMNode
*node
= NULL
;
1289 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1290 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
1293 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
1294 IHTMLDocument3_Release(doc3
);
1295 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
1296 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
1301 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
1302 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
1304 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
1305 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
1306 IHTMLDOMNode
*new_child
= NULL
;
1309 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
1310 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
1311 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
1312 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
1314 IHTMLDOMNode_Release(node
);
1315 IHTMLDOMNode_Release(child
);
1320 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
1321 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
1323 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1324 IHTMLDOMNode
*new_node
= NULL
;
1327 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
1328 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
1329 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
1330 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
1332 IHTMLDOMNode_Release(node
);
1333 IHTMLDOMNode_Release(new_node
);
1336 static void test_elem_col_item(IHTMLElementCollection
*col
, LPCWSTR n
,
1337 const elem_type_t
*elem_types
, long len
)
1340 VARIANT name
, index
;
1344 V_VT(&index
) = VT_EMPTY
;
1345 V_VT(&name
) = VT_BSTR
;
1346 V_BSTR(&name
) = SysAllocString(n
);
1348 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1349 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1351 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
1352 IDispatch_Release(disp
);
1353 ok(hres
== S_OK
, "Could not get IHTMLElementCollection interface: %08x\n", hres
);
1357 V_VT(&index
) = VT_I4
;
1359 for(i
=0; i
<len
; i
++) {
1361 disp
= (void*)0xdeadbeef;
1362 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1363 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1364 ok(disp
!= NULL
, "disp == NULL\n");
1365 if(FAILED(hres
) || !disp
)
1368 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
1370 IDispatch_Release(disp
);
1374 disp
= (void*)0xdeadbeef;
1375 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1376 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1377 ok(disp
== NULL
, "disp != NULL\n");
1380 disp
= (void*)0xdeadbeef;
1381 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1382 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1383 ok(disp
== NULL
, "disp != NULL\n");
1386 SysFreeString(V_BSTR(&name
));
1389 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, LPCWSTR id
, BOOL expect_success
)
1391 IHTMLElementCollection
*col
;
1393 IDispatch
*disp
= (void*)0xdeadbeef;
1394 VARIANT name
, index
;
1397 hres
= IHTMLDocument2_get_all(doc
, &col
);
1398 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1399 ok(col
!= NULL
, "col == NULL\n");
1400 if(FAILED(hres
) || !col
)
1403 V_VT(&index
) = VT_EMPTY
;
1404 V_VT(&name
) = VT_BSTR
;
1405 V_BSTR(&name
) = SysAllocString(id
);
1407 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1408 IHTMLElementCollection_Release(col
);
1409 SysFreeString(V_BSTR(&name
));
1410 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1411 if(!expect_success
) {
1412 ok(disp
== NULL
, "disp != NULL\n");
1416 ok(disp
!= NULL
, "disp == NULL\n");
1420 elem
= get_elem_iface((IUnknown
*)disp
);
1421 IDispatch_Release(disp
);
1426 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, LPCWSTR id
)
1428 IHTMLDocument3
*doc3
;
1433 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1434 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
1436 tmp
= SysAllocString(id
);
1437 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
1439 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", dbgstr_w(id
), hres
);
1441 IHTMLDocument3_Release(doc3
);
1446 static void test_select_elem(IHTMLSelectElement
*select
)
1448 test_select_type(select
, "select-one");
1449 test_select_length(select
, 2);
1450 test_select_selidx(select
, 0);
1451 test_select_put_selidx(select
, 1);
1453 test_select_set_value(select
, "val1");
1454 test_select_value(select
, "val1");
1457 static void test_create_option_elem(IHTMLDocument2
*doc
)
1459 IHTMLOptionElement
*option
;
1461 option
= create_option_elem(doc
, "test text", "test value");
1463 test_option_put_text(option
, "new text");
1464 test_option_put_value(option
, "new value");
1466 IHTMLOptionElement_Release(option
);
1469 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
1471 IHTMLBodyElement
*body
;
1472 IHTMLTxtRange
*range
;
1476 hres
= IHTMLDocument2_get_body(doc
, &elem
);
1477 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1479 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
1480 IHTMLElement_Release(elem
);
1482 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
1483 IHTMLBodyElement_Release(body
);
1484 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
1489 static void test_txtrange(IHTMLDocument2
*doc
)
1491 IHTMLTxtRange
*body_range
, *range
, *range2
;
1492 IHTMLSelectionObject
*selection
;
1493 IDispatch
*disp_range
;
1496 body_range
= test_create_body_range(doc
);
1498 test_range_text(body_range
, "test abc 123\r\nit's text");
1500 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1501 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1503 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
1504 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1505 test_range_isequal(range
, range2
, VARIANT_TRUE
);
1507 test_range_text(range
, "test abc 123\r\nit's text");
1508 test_range_text(body_range
, "test abc 123\r\nit's text");
1510 test_range_collapse(range
, TRUE
);
1511 test_range_isequal(range
, range2
, VARIANT_FALSE
);
1512 test_range_inrange(range
, range2
, VARIANT_FALSE
);
1513 test_range_inrange(range2
, range
, VARIANT_TRUE
);
1514 IHTMLTxtRange_Release(range2
);
1516 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1517 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
1518 test_range_move(range
, characterW
, 2, 2);
1519 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1521 test_range_collapse(range
, FALSE
);
1522 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
1524 test_range_collapse(range
, FALSE
);
1525 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
1526 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
1527 test_range_move(range
, characterW
, 2, 2);
1528 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
1529 test_range_moveend(range
, characterW
, -5, -5);
1530 test_range_text(range
, NULL
);
1531 test_range_moveend(range
, characterW
, 3, 3);
1532 test_range_text(range
, "c 1");
1533 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
1534 test_range_collapse(range
, TRUE
);
1535 test_range_move(range
, characterW
, 4, 4);
1536 test_range_moveend(range
, characterW
, 1, 1);
1537 test_range_text(range
, " ");
1538 test_range_move(range
, wordW
, 1, 1);
1539 test_range_moveend(range
, characterW
, 2, 2);
1540 test_range_text(range
, "ab");
1542 IHTMLTxtRange_Release(range
);
1544 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1545 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1547 test_range_text(range
, "test abc 123\r\nit's text");
1548 test_range_move(range
, characterW
, 3, 3);
1549 test_range_moveend(range
, characterW
, 1, 1);
1550 test_range_text(range
, "t");
1551 test_range_moveend(range
, characterW
, 3, 3);
1552 test_range_text(range
, "t ab");
1553 test_range_moveend(range
, characterW
, -2, -2);
1554 test_range_text(range
, "t ");
1555 test_range_move(range
, characterW
, 6, 6);
1556 test_range_moveend(range
, characterW
, 3, 3);
1557 test_range_text(range
, "123");
1558 test_range_moveend(range
, characterW
, 2, 2);
1559 test_range_text(range
, "123\r\ni");
1561 IHTMLTxtRange_Release(range
);
1563 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1564 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1566 test_range_move(range
, wordW
, 1, 1);
1567 test_range_moveend(range
, characterW
, 2, 2);
1568 test_range_text(range
, "ab");
1570 test_range_move(range
, characterW
, -2, -2);
1571 test_range_moveend(range
, characterW
, 2, 2);
1572 test_range_text(range
, "t ");
1574 test_range_move(range
, wordW
, 3, 3);
1575 test_range_move(range
, wordW
, -2, -2);
1576 test_range_moveend(range
, characterW
, 2, 2);
1577 test_range_text(range
, "ab");
1579 test_range_move(range
, characterW
, -6, -5);
1580 test_range_moveend(range
, characterW
, -1, 0);
1581 test_range_moveend(range
, characterW
, -6, 0);
1582 test_range_move(range
, characterW
, 2, 2);
1583 test_range_moveend(range
, characterW
, 2, 2);
1584 test_range_text(range
, "st");
1585 test_range_moveend(range
, characterW
, -6, -4);
1586 test_range_moveend(range
, characterW
, 2, 2);
1588 IHTMLTxtRange_Release(range
);
1590 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1591 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1593 test_range_move(range
, wordW
, 2, 2);
1594 test_range_moveend(range
, characterW
, 2, 2);
1595 test_range_text(range
, "12");
1597 test_range_move(range
, characterW
, 15, 14);
1598 test_range_move(range
, characterW
, -2, -2);
1599 test_range_moveend(range
, characterW
, 3, 2);
1600 test_range_text(range
, "t");
1601 test_range_moveend(range
, characterW
, -1, -1);
1602 test_range_text(range
, "t");
1603 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
1604 test_range_move(range
, characterW
, -2, -2);
1605 test_range_moveend(range
, characterW
, 2, 2);
1606 test_range_text(range
, "s ");
1607 test_range_move(range
, characterW
, 100, 7);
1608 test_range_move(range
, wordW
, 1, 0);
1609 test_range_move(range
, characterW
, -2, -2);
1610 test_range_moveend(range
, characterW
, 3, 2);
1611 test_range_text(range
, "t");
1613 IHTMLTxtRange_Release(range
);
1615 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1616 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1618 test_range_collapse(range
, TRUE
);
1619 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1620 test_range_put_text(range
, "word");
1621 test_range_text(body_range
, "wordabc 123\r\nit's text");
1622 test_range_text(range
, NULL
);
1623 test_range_moveend(range
, characterW
, 3, 3);
1624 test_range_text(range
, "abc");
1625 test_range_movestart(range
, characterW
, -2, -2);
1626 test_range_text(range
, "rdabc");
1627 test_range_movestart(range
, characterW
, 3, 3);
1628 test_range_text(range
, "bc");
1629 test_range_movestart(range
, characterW
, 4, 4);
1630 test_range_text(range
, NULL
);
1631 test_range_movestart(range
, characterW
, -3, -3);
1632 test_range_text(range
, "c 1");
1633 test_range_movestart(range
, characterW
, -7, -6);
1634 test_range_text(range
, "wordabc 1");
1635 test_range_movestart(range
, characterW
, 100, 22);
1636 test_range_text(range
, NULL
);
1638 IHTMLTxtRange_Release(range
);
1639 IHTMLTxtRange_Release(body_range
);
1641 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
1642 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
1644 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
1645 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
1646 IHTMLSelectionObject_Release(selection
);
1648 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
1649 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
1650 IDispatch_Release(disp_range
);
1652 test_range_text(range
, NULL
);
1653 test_range_moveend(range
, characterW
, 3, 3);
1654 test_range_text(range
, "wor");
1655 test_range_parent(range
, ET_BODY
);
1656 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
1657 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
1658 test_range_move(range
, characterW
, 3, 3);
1659 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
1660 test_range_moveend(range
, characterW
, -4, -4);
1661 test_range_put_text(range
, "abc def ");
1662 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
1663 test_range_move(range
, wordW
, 1, 1);
1664 test_range_movestart(range
, characterW
, -1, -1);
1665 test_range_text(range
, " ");
1666 test_range_move(range
, wordW
, 1, 1);
1667 test_range_moveend(range
, characterW
, 3, 3);
1668 test_range_text(range
, "def");
1669 test_range_put_text(range
, "xyz");
1670 test_range_moveend(range
, characterW
, 1, 1);
1671 test_range_move(range
, wordW
, 1, 1);
1672 test_range_moveend(range
, characterW
, 2, 2);
1673 test_range_text(range
, "ab");
1675 IHTMLTxtRange_Release(range
);
1678 static void test_txtrange2(IHTMLDocument2
*doc
)
1680 IHTMLTxtRange
*range
;
1682 range
= test_create_body_range(doc
);
1684 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
1685 test_range_move(range
, characterW
, 5, 5);
1686 test_range_moveend(range
, characterW
, 1, 1);
1687 test_range_text(range
, "2");
1688 test_range_move(range
, characterW
, -3, -3);
1689 test_range_moveend(range
, characterW
, 3, 3);
1690 test_range_text(range
, "c\r\n\r\n1");
1691 test_range_collapse(range
, VARIANT_FALSE
);
1692 test_range_moveend(range
, characterW
, 4, 4);
1693 test_range_text(range
, "23");
1694 test_range_moveend(range
, characterW
, 1, 1);
1695 test_range_text(range
, "23\r\n\r\n\r\nd");
1696 test_range_moveend(range
, characterW
, -1, -1);
1697 test_range_text(range
, "23");
1698 test_range_moveend(range
, characterW
, -1, -1);
1699 test_range_text(range
, "23");
1700 test_range_moveend(range
, characterW
, -2, -2);
1701 test_range_text(range
, "2");
1703 IHTMLTxtRange_Release(range
);
1706 static void test_compatmode(IHTMLDocument2
*doc
)
1708 IHTMLDocument5
*doc5
;
1712 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
1713 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
1717 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
1718 IHTMLDocument5_Release(doc5
);
1719 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
1720 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", dbgstr_w(mode
));
1721 SysFreeString(mode
);
1724 static void test_location(IHTMLDocument2
*doc
)
1726 IHTMLLocation
*location
, *location2
;
1730 hres
= IHTMLDocument2_get_location(doc
, &location
);
1731 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
1733 hres
= IHTMLDocument2_get_location(doc
, &location2
);
1734 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
1736 ok(location
== location2
, "location != location2\n");
1738 test_ifaces((IUnknown
*)location
, location_iids
);
1740 IHTMLLocation_Release(location2
);
1741 ref
= IHTMLLocation_Release(location
);
1742 ok(!ref
, "location chould be destroyed here\n");
1745 static void test_navigator(IHTMLDocument2
*doc
)
1747 IHTMLWindow2
*window
;
1748 IOmNavigator
*navigator
, *navigator2
;
1752 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1753 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
1755 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
1756 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
1757 ok(navigator
!= NULL
, "navigator == NULL\n");
1758 test_disp((IUnknown
*)navigator
, &IID_IOmNavigator
);
1760 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
1761 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
1762 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
1764 IHTMLWindow2_Release(window
);
1765 IOmNavigator_Release(navigator2
);
1766 ref
= IOmNavigator_Release(navigator
);
1767 ok(!ref
, "navigator should be destroyed here\n");
1770 static void test_default_style(IHTMLStyle
*style
)
1777 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
);
1779 str
= (void*)0xdeadbeef;
1780 hres
= IHTMLStyle_get_fontFamily(style
, &str
);
1781 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
1782 ok(!str
, "fontFamily = %s\n", dbgstr_w(str
));
1784 str
= (void*)0xdeadbeef;
1785 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
1786 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
1787 ok(!str
, "fontWeight = %s\n", dbgstr_w(str
));
1789 str
= (void*)0xdeadbeef;
1790 hres
= IHTMLStyle_get_display(style
, &str
);
1791 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
1792 ok(!str
, "display = %s\n", dbgstr_w(str
));
1794 str
= (void*)0xdeadbeef;
1795 hres
= IHTMLStyle_get_visibility(style
, &str
);
1796 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
1797 ok(!str
, "visibility = %s\n", dbgstr_w(str
));
1800 hres
= IHTMLStyle_get_fontSize(style
, &v
);
1801 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
1802 ok(V_VT(&v
) == VT_BSTR
, "V_VT(fontSize) = %d\n", V_VT(&v
));
1803 ok(!V_BSTR(&v
), "V_BSTR(fontSize) = %s\n", dbgstr_w(V_BSTR(&v
)));
1806 hres
= IHTMLStyle_get_color(style
, &v
);
1807 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
1808 ok(V_VT(&v
) == VT_BSTR
, "V_VT(color) = %d\n", V_VT(&v
));
1809 ok(!V_BSTR(&v
), "V_BSTR(color) = %s\n", dbgstr_w(V_BSTR(&v
)));
1812 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
1813 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
1814 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
1817 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
1818 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
1819 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
1821 V_VT(&v
) = VT_EMPTY
;
1822 hres
= IHTMLStyle_get_width(style
, &v
);
1823 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
1824 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
1825 ok(!V_BSTR(&v
), "V_BSTR(v)=%p\n", V_BSTR(&v
));
1828 V_BSTR(&v
) = a2bstr("auto");
1829 hres
= IHTMLStyle_put_width(style
, v
);
1830 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
1833 V_VT(&v
) = VT_EMPTY
;
1834 hres
= IHTMLStyle_get_width(style
, &v
);
1835 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
1836 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
1837 ok(!strcmp_wa(V_BSTR(&v
), "auto"), "V_BSTR(v)=%s\n", dbgstr_w(V_BSTR(&v
)));
1841 static void test_default_selection(IHTMLDocument2
*doc
)
1843 IHTMLSelectionObject
*selection
;
1844 IHTMLTxtRange
*range
;
1849 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
1850 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
1852 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
1853 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1854 ok(!lstrcmpW(str
, noneW
), "type = %s\n", dbgstr_w(str
));
1857 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
1858 IHTMLSelectionObject_Release(selection
);
1859 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
1861 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
1862 IDispatch_Release(disp
);
1863 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
1865 test_range_text(range
, NULL
);
1866 IHTMLTxtRange_Release(range
);
1869 static void test_default_body(IHTMLBodyElement
*body
)
1874 bstr
= (void*)0xdeadbeef;
1875 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
1876 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
1877 ok(bstr
== NULL
, "bstr != NULL\n");
1880 static void test_window(IHTMLDocument2
*doc
)
1882 IHTMLWindow2
*window
, *window2
, *self
;
1883 IHTMLDocument2
*doc2
= NULL
;
1886 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1887 ok(hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1888 test_ifaces((IUnknown
*)window
, window_iids
);
1889 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
);
1891 hres
= IHTMLWindow2_get_document(window
, &doc2
);
1892 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1893 ok(doc2
!= NULL
, "doc2 == NULL\n");
1895 IHTMLDocument_Release(doc2
);
1897 hres
= IHTMLWindow2_get_window(window
, &window2
);
1898 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
1899 ok(window2
!= NULL
, "window2 == NULL\n");
1901 hres
= IHTMLWindow2_get_self(window
, &self
);
1902 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
1903 ok(window2
!= NULL
, "self == NULL\n");
1905 ok(self
== window2
, "self != window2\n");
1907 IHTMLWindow2_Release(window2
);
1908 IHTMLWindow2_Release(self
);
1910 IHTMLWindow2_Release(window
);
1913 static void test_defaults(IHTMLDocument2
*doc
)
1915 IHTMLStyleSheetsCollection
*stylesheetcol
;
1916 IHTMLBodyElement
*body
;
1922 hres
= IHTMLDocument2_get_body(doc
, &elem
);
1923 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1925 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
1926 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
1927 test_default_body(body
);
1928 IHTMLBodyElement_Release(body
);
1930 hres
= IHTMLElement_get_style(elem
, &style
);
1931 IHTMLElement_Release(elem
);
1932 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
1934 test_default_style(style
);
1936 test_compatmode(doc
);
1938 test_navigator(doc
);
1940 IHTMLStyle_Release(style
);
1942 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
1943 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
1946 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
1947 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1948 ok(l
== 0, "length = %ld\n", l
);
1950 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
1952 test_default_selection(doc
);
1955 static void test_stylesheet(IDispatch
*disp
)
1957 IHTMLStyleSheetRulesCollection
*col
= NULL
;
1958 IHTMLStyleSheet
*stylesheet
;
1961 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
1962 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
1964 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
1965 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
1966 ok(col
!= NULL
, "col == NULL\n");
1968 IHTMLStyleSheetRulesCollection_Release(col
);
1969 IHTMLStyleSheet_Release(stylesheet
);
1972 static void test_stylesheets(IHTMLDocument2
*doc
)
1974 IHTMLStyleSheetsCollection
*col
= NULL
;
1979 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
1980 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
1981 ok(col
!= NULL
, "col == NULL\n");
1983 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
1984 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1985 ok(len
== 1, "len=%ld\n", len
);
1991 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
1992 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1993 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
1994 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
1995 test_stylesheet(V_DISPATCH(&res
));
2002 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
2003 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2004 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
2005 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
2008 IHTMLStyleSheetsCollection_Release(col
);
2011 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
2013 IDispatchEx
*dispex
;
2015 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
2023 static const WCHAR w0
[] = {'0',0};
2024 static const WCHAR w100
[] = {'1','0','0',0};
2026 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
2027 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
2029 bstr
= SysAllocString(w0
);
2030 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
2031 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2032 SysFreeString(bstr
);
2035 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2036 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2037 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
2038 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
2039 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
2040 type
= get_node_type((IUnknown
*)node
);
2041 ok(type
== 3, "type=%ld\n", type
);
2042 IHTMLDOMNode_Release(node
);
2045 bstr
= SysAllocString(w100
);
2046 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
2047 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
2048 SysFreeString(bstr
);
2050 IDispatchEx_Release(dispex
);
2055 static void test_elems(IHTMLDocument2
*doc
)
2057 IHTMLElementCollection
*col
;
2058 IHTMLDOMChildrenCollection
*child_col
;
2060 IHTMLDOMNode
*node
, *node2
;
2065 static const WCHAR imgidW
[] = {'i','m','g','i','d',0};
2066 static const WCHAR inW
[] = {'i','n',0};
2067 static const WCHAR xW
[] = {'x',0};
2068 static const WCHAR sW
[] = {'s',0};
2069 static const WCHAR scW
[] = {'s','c',0};
2070 static const WCHAR xxxW
[] = {'x','x','x',0};
2072 static const elem_type_t all_types
[] = {
2092 static const elem_type_t item_types
[] = {
2098 hres
= IHTMLDocument2_get_all(doc
, &col
);
2099 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2100 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
2101 test_elem_col_item(col
, xW
, item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
2102 IHTMLElementCollection_Release(col
);
2104 elem
= get_doc_elem(doc
);
2105 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
2106 hres
= IHTMLElement_get_all(elem
, &disp
);
2107 IHTMLElement_Release(elem
);
2108 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2110 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLElementCollection
, (void**)&col
);
2111 IDispatch_Release(disp
);
2112 ok(hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2113 test_elem_collection((IUnknown
*)col
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
2114 IHTMLElementCollection_Release(col
);
2116 get_elem_by_id(doc
, xxxW
, FALSE
);
2117 elem
= get_doc_elem_by_id(doc
, xxxW
);
2118 ok(!elem
, "elem != NULL\n");
2120 elem
= get_doc_elem_by_id(doc
, sW
);
2121 ok(elem
!= NULL
, "elem == NULL\n");
2123 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
2124 test_elem_attr(elem
, xxxW
, NULL
);
2125 test_elem_attr(elem
, idW
, sW
);
2126 test_elem_class((IUnknown
*)elem
, NULL
);
2127 test_elem_set_class((IUnknown
*)elem
, "cl");
2128 test_elem_set_class((IUnknown
*)elem
, NULL
);
2129 test_elem_tabindex((IUnknown
*)elem
, 0);
2130 test_elem_set_tabindex((IUnknown
*)elem
, 1);
2132 node
= test_node_get_parent((IUnknown
*)elem
);
2133 ok(node
!= NULL
, "node == NULL\n");
2134 test_node_name((IUnknown
*)node
, "BODY");
2135 node2
= test_node_get_parent((IUnknown
*)node
);
2136 IHTMLDOMNode_Release(node
);
2137 ok(node2
!= NULL
, "node == NULL\n");
2138 test_node_name((IUnknown
*)node2
, "HTML");
2139 node
= test_node_get_parent((IUnknown
*)node2
);
2140 IHTMLDOMNode_Release(node2
);
2141 ok(node
!= NULL
, "node == NULL\n");
2142 test_node_name((IUnknown
*)node
, "#document");
2143 type
= get_node_type((IUnknown
*)node
);
2144 ok(type
== 9, "type=%ld, expected 9\n", type
);
2145 node2
= test_node_get_parent((IUnknown
*)node
);
2146 IHTMLDOMNode_Release(node
);
2147 ok(node2
== NULL
, "node != NULL\n");
2149 IHTMLElement_Release(elem
);
2152 elem
= get_elem_by_id(doc
, sW
, TRUE
);
2154 IHTMLSelectElement
*select
;
2156 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLSelectElement
, (void**)&select
);
2157 ok(hres
== S_OK
, "Could not get IHTMLSelectElement interface: %08x\n", hres
);
2159 test_select_elem(select
);
2161 test_elem_title((IUnknown
*)select
, NULL
);
2162 test_elem_set_title((IUnknown
*)select
, "Title");
2163 test_elem_title((IUnknown
*)select
, "Title");
2164 test_elem_offset((IUnknown
*)select
);
2166 node
= get_first_child((IUnknown
*)select
);
2167 ok(node
!= NULL
, "node == NULL\n");
2169 test_elem_type((IUnknown
*)node
, ET_OPTION
);
2170 IHTMLDOMNode_Release(node
);
2173 type
= get_node_type((IUnknown
*)select
);
2174 ok(type
== 1, "type=%ld\n", type
);
2176 IHTMLSelectElement_Release(select
);
2177 IHTMLElement_Release(elem
);
2180 elem
= get_elem_by_id(doc
, scW
, TRUE
);
2182 IHTMLScriptElement
*script
;
2185 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
2186 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
2188 hres
= IHTMLScriptElement_get_type(script
, &type
);
2189 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
2190 ok(!lstrcmpW(type
, text_javascriptW
), "Unexpected type %s\n", dbgstr_w(type
));
2191 SysFreeString(type
);
2193 IHTMLScriptElement_Release(script
);
2196 elem
= get_elem_by_id(doc
, inW
, TRUE
);
2198 IHTMLInputElement
*input
;
2200 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
2201 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2203 test_elem_id((IUnknown
*)elem
, "in");
2204 test_elem_put_id((IUnknown
*)elem
, "newin");
2205 test_input_get_disabled(input
, VARIANT_FALSE
);
2206 test_input_set_disabled(input
, VARIANT_TRUE
);
2207 test_input_set_disabled(input
, VARIANT_FALSE
);
2208 test_elem_client_size((IUnknown
*)elem
);
2210 test_node_get_value_str((IUnknown
*)elem
, NULL
);
2211 test_node_put_value_str((IUnknown
*)elem
, "test");
2212 test_node_get_value_str((IUnknown
*)elem
, NULL
);
2213 test_input_value((IUnknown
*)elem
, NULL
);
2214 test_input_put_value((IUnknown
*)elem
, "test");
2215 test_input_value((IUnknown
*)elem
, NULL
);
2216 test_elem_class((IUnknown
*)elem
, "testclass");
2217 test_elem_tabindex((IUnknown
*)elem
, 2);
2218 test_elem_set_tabindex((IUnknown
*)elem
, 3);
2219 test_elem_title((IUnknown
*)elem
, "test title");
2221 IHTMLInputElement_Release(input
);
2222 IHTMLElement_Release(elem
);
2225 elem
= get_elem_by_id(doc
, imgidW
, TRUE
);
2227 test_img_set_src((IUnknown
*)elem
, "about:blank");
2228 test_img_alt((IUnknown
*)elem
, NULL
);
2229 test_img_set_alt((IUnknown
*)elem
, "alt test");
2230 IHTMLElement_Release(elem
);
2233 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2234 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2236 node
= get_first_child((IUnknown
*)elem
);
2237 ok(node
!= NULL
, "node == NULL\n");
2239 test_ifaces((IUnknown
*)node
, text_iids
);
2240 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
);
2242 node2
= get_first_child((IUnknown
*)node
);
2243 ok(!node2
, "node2 != NULL\n");
2245 type
= get_node_type((IUnknown
*)node
);
2246 ok(type
== 3, "type=%ld\n", type
);
2248 test_node_get_value_str((IUnknown
*)node
, "text test");
2249 test_node_put_value_str((IUnknown
*)elem
, "test text");
2250 test_node_get_value_str((IUnknown
*)node
, "text test");
2252 IHTMLDOMNode_Release(node
);
2255 child_col
= get_child_nodes((IUnknown
*)elem
);
2256 ok(child_col
!= NULL
, "child_coll == NULL\n");
2260 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
);
2262 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
2263 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2264 ok(length
, "length=0\n");
2266 node
= get_child_item(child_col
, 0);
2267 ok(node
!= NULL
, "node == NULL\n");
2269 type
= get_node_type((IUnknown
*)node
);
2270 ok(type
== 3, "type=%ld\n", type
);
2271 IHTMLDOMNode_Release(node
);
2274 node
= get_child_item(child_col
, 1);
2275 ok(node
!= NULL
, "node == NULL\n");
2277 type
= get_node_type((IUnknown
*)node
);
2278 ok(type
== 8, "type=%ld\n", type
);
2280 test_elem_id((IUnknown
*)node
, NULL
);
2281 IHTMLDOMNode_Release(node
);
2284 disp
= (void*)0xdeadbeef;
2285 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
2286 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2287 ok(disp
== (void*)0xdeadbeef, "disp=%p\n", disp
);
2289 disp
= (void*)0xdeadbeef;
2290 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
2291 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2292 ok(disp
== (void*)0xdeadbeef, "disp=%p\n", disp
);
2294 test_child_col_disp(child_col
);
2296 IHTMLDOMChildrenCollection_Release(child_col
);
2299 IHTMLElement_Release(elem
);
2301 test_stylesheets(doc
);
2302 test_create_option_elem(doc
);
2305 static void test_create_elems(IHTMLDocument2
*doc
)
2307 IHTMLElement
*elem
, *body
, *elem2
;
2313 static const elem_type_t types1
[] = { ET_TESTG
};
2315 elem
= test_create_elem(doc
, "TEST");
2316 test_elem_tag((IUnknown
*)elem
, "TEST");
2317 type
= get_node_type((IUnknown
*)elem
);
2318 ok(type
== 1, "type=%ld\n", type
);
2319 test_ifaces((IUnknown
*)elem
, elem_iids
);
2320 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
);
2322 hres
= IHTMLDocument2_get_body(doc
, &body
);
2323 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2324 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
2326 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
2327 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
2328 elem2
= get_elem_iface((IUnknown
*)node
);
2329 IHTMLElement_Release(elem2
);
2331 hres
= IHTMLElement_get_all(body
, &disp
);
2332 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2333 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
2334 IDispatch_Release(disp
);
2336 test_node_remove_child((IUnknown
*)body
, node
);
2338 hres
= IHTMLElement_get_all(body
, &disp
);
2339 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2340 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
2341 IDispatch_Release(disp
);
2342 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
2344 IHTMLElement_Release(body
);
2345 IHTMLElement_Release(elem
);
2346 IHTMLDOMNode_Release(node
);
2348 node
= test_create_text(doc
, "test");
2349 test_ifaces((IUnknown
*)node
, text_iids
);
2350 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
);
2351 IHTMLDOMNode_Release(node
);
2354 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
2356 IOleCommandTarget
*cmdtrg
;
2359 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
2360 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
2362 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
2363 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
2365 IOleCommandTarget_Release(cmdtrg
);
2368 static void test_indent(IHTMLDocument2
*doc
)
2370 IHTMLElementCollection
*col
;
2371 IHTMLTxtRange
*range
;
2374 static const elem_type_t all_types
[] = {
2383 static const elem_type_t indent_types
[] = {
2394 hres
= IHTMLDocument2_get_all(doc
, &col
);
2395 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2396 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
2397 IHTMLElementCollection_Release(col
);
2399 range
= test_create_body_range(doc
);
2400 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
2401 IHTMLTxtRange_Release(range
);
2403 hres
= IHTMLDocument2_get_all(doc
, &col
);
2404 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2405 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
2406 IHTMLElementCollection_Release(col
);
2409 static IHTMLDocument2
*notif_doc
;
2410 static BOOL doc_complete
;
2412 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
2413 REFIID riid
, void**ppv
)
2415 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
2420 ok(0, "unexpected call\n");
2421 return E_NOINTERFACE
;
2424 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
2429 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
2434 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
2436 if(dispID
== DISPID_READYSTATE
){
2440 static const WCHAR completeW
[] = {'c','o','m','p','l','e','t','e',0};
2442 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
2443 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
2445 if(!lstrcmpW(state
, completeW
))
2446 doc_complete
= TRUE
;
2448 SysFreeString(state
);
2454 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
2456 ok(0, "unexpected call\n");
2460 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
2461 PropertyNotifySink_QueryInterface
,
2462 PropertyNotifySink_AddRef
,
2463 PropertyNotifySink_Release
,
2464 PropertyNotifySink_OnChanged
,
2465 PropertyNotifySink_OnRequestEdit
2468 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
2470 static IHTMLDocument2
*create_doc_with_string(const char *str
)
2472 IPersistStreamInit
*init
;
2474 IHTMLDocument2
*doc
;
2478 notif_doc
= doc
= create_document();
2482 doc_complete
= FALSE
;
2484 mem
= GlobalAlloc(0, len
);
2485 memcpy(mem
, str
, len
);
2486 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
2488 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
2490 IPersistStreamInit_Load(init
, stream
);
2491 IPersistStreamInit_Release(init
);
2492 IStream_Release(stream
);
2497 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
2499 IConnectionPointContainer
*container
;
2500 IConnectionPoint
*cp
;
2504 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
2505 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
2507 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
2508 IConnectionPointContainer_Release(container
);
2509 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
2511 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
2512 IConnectionPoint_Release(cp
);
2513 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
2516 typedef void (*domtest_t
)(IHTMLDocument2
*);
2518 static void run_domtest(const char *str
, domtest_t test
)
2520 IHTMLDocument2
*doc
;
2521 IHTMLElement
*body
= NULL
;
2526 doc
= create_doc_with_string(str
);
2527 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
2529 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
2530 TranslateMessage(&msg
);
2531 DispatchMessage(&msg
);
2534 hres
= IHTMLDocument2_get_body(doc
, &body
);
2535 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2538 IHTMLElement_Release(body
);
2541 skip("Could not get document body. Assuming no Gecko installed.\n");
2544 ref
= IHTMLDocument2_Release(doc
);
2545 ok(!ref
, "ref = %d\n", ref
);
2548 static void gecko_installer_workaround(BOOL disable
)
2553 static BOOL has_url
= FALSE
;
2554 static char url
[2048];
2556 if(!disable
&& !has_url
)
2559 res
= RegOpenKey(HKEY_CURRENT_USER
, "Software\\Wine\\MSHTML", &hkey
);
2560 if(res
!= ERROR_SUCCESS
)
2564 DWORD type
, size
= sizeof(url
);
2566 res
= RegQueryValueEx(hkey
, "GeckoUrl", NULL
, &type
, (PVOID
)url
, &size
);
2567 if(res
== ERROR_SUCCESS
&& type
== REG_SZ
)
2570 RegDeleteValue(hkey
, "GeckoUrl");
2572 RegSetValueEx(hkey
, "GeckoUrl", 0, REG_SZ
, (PVOID
)url
, lstrlenA(url
)+1);
2580 gecko_installer_workaround(TRUE
);
2583 run_domtest(doc_str1
, test_doc_elem
);
2584 run_domtest(range_test_str
, test_txtrange
);
2585 run_domtest(range_test2_str
, test_txtrange2
);
2586 run_domtest(elem_test_str
, test_elems
);
2587 run_domtest(doc_blank
, test_create_elems
);
2588 run_domtest(doc_blank
, test_defaults
);
2589 run_domtest(indent_test_str
, test_indent
);
2592 gecko_installer_workaround(FALSE
);