mshtml: Match IE8 implementation.
[wine/hacks.git] / dlls / mshtml / tests / dom.c
blob497fc0ac668405459a947889072fef11d7269777
1 /*
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
19 #define COBJMACROS
20 #define CONST_VTABLE
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ole2.h"
29 #include "mshtml.h"
30 #include "mshtmcid.h"
31 #include "mshtmhst.h"
32 #include "docobj.h"
33 #include "dispex.h"
35 static const char doc_blank[] = "<html></html>";
36 static const char doc_str1[] = "<html><body>test</body></html>";
37 static const char range_test_str[] =
38 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
39 static const char range_test2_str[] =
40 "<html><body>abc<hr />123<br /><hr />def</body></html>";
41 static const char elem_test_str[] =
42 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
43 "<body onload=\"Testing()\">text test<!-- a comment -->"
44 "<a href=\"http://test\" name=\"x\">link</a>"
45 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
46 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
47 "<textarea id=\"X\">text text</textarea>"
48 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
49 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
50 "<test />"
51 "<img id=\"imgid\"/>"
52 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
53 "</body></html>";
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]-->"
59 "</body></html>";
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 typedef enum {
70 ET_NONE,
71 ET_HTML,
72 ET_HEAD,
73 ET_TITLE,
74 ET_BODY,
75 ET_A,
76 ET_INPUT,
77 ET_SELECT,
78 ET_TEXTAREA,
79 ET_OPTION,
80 ET_STYLE,
81 ET_BLOCKQUOTE,
82 ET_P,
83 ET_BR,
84 ET_TABLE,
85 ET_TBODY,
86 ET_SCRIPT,
87 ET_TEST,
88 ET_TESTG,
89 ET_COMMENT,
90 ET_IMG,
91 ET_TR,
92 ET_TD,
93 ET_IFRAME
94 } elem_type_t;
96 static const IID * const none_iids[] = {
97 &IID_IUnknown,
98 NULL
101 static const IID * const elem_iids[] = {
102 &IID_IHTMLDOMNode,
103 &IID_IHTMLDOMNode2,
104 &IID_IHTMLElement,
105 &IID_IHTMLElement2,
106 &IID_IHTMLElement3,
107 &IID_IDispatchEx,
108 &IID_IConnectionPointContainer,
109 NULL
112 static const IID * const body_iids[] = {
113 &IID_IHTMLDOMNode,
114 &IID_IHTMLDOMNode2,
115 &IID_IHTMLElement,
116 &IID_IHTMLElement2,
117 &IID_IHTMLElement3,
118 &IID_IHTMLTextContainer,
119 &IID_IHTMLBodyElement,
120 &IID_IDispatchEx,
121 &IID_IConnectionPointContainer,
122 NULL
125 static const IID * const anchor_iids[] = {
126 &IID_IHTMLDOMNode,
127 &IID_IHTMLDOMNode2,
128 &IID_IHTMLElement,
129 &IID_IHTMLElement2,
130 &IID_IHTMLElement3,
131 &IID_IHTMLAnchorElement,
132 &IID_IDispatchEx,
133 &IID_IConnectionPointContainer,
134 NULL
137 static const IID * const input_iids[] = {
138 &IID_IHTMLDOMNode,
139 &IID_IHTMLDOMNode2,
140 &IID_IHTMLElement,
141 &IID_IHTMLElement2,
142 &IID_IHTMLElement3,
143 &IID_IHTMLInputElement,
144 &IID_IHTMLInputTextElement,
145 &IID_IDispatchEx,
146 &IID_IConnectionPointContainer,
147 NULL
150 static const IID * const select_iids[] = {
151 &IID_IHTMLDOMNode,
152 &IID_IHTMLDOMNode2,
153 &IID_IHTMLElement,
154 &IID_IHTMLElement2,
155 &IID_IHTMLElement3,
156 &IID_IHTMLSelectElement,
157 &IID_IDispatchEx,
158 &IID_IConnectionPointContainer,
159 NULL
162 static const IID * const textarea_iids[] = {
163 &IID_IHTMLDOMNode,
164 &IID_IHTMLDOMNode2,
165 &IID_IHTMLElement,
166 &IID_IHTMLElement2,
167 &IID_IHTMLElement3,
168 &IID_IHTMLTextAreaElement,
169 &IID_IDispatchEx,
170 &IID_IConnectionPointContainer,
171 NULL
174 static const IID * const option_iids[] = {
175 &IID_IHTMLDOMNode,
176 &IID_IHTMLDOMNode2,
177 &IID_IHTMLElement,
178 &IID_IHTMLElement2,
179 &IID_IHTMLElement3,
180 &IID_IHTMLOptionElement,
181 &IID_IDispatchEx,
182 &IID_IConnectionPointContainer,
183 NULL
186 static const IID * const table_iids[] = {
187 &IID_IHTMLDOMNode,
188 &IID_IHTMLDOMNode2,
189 &IID_IHTMLElement,
190 &IID_IHTMLElement2,
191 &IID_IHTMLElement3,
192 &IID_IHTMLTable,
193 &IID_IDispatchEx,
194 &IID_IConnectionPointContainer,
195 NULL
198 static const IID * const script_iids[] = {
199 &IID_IHTMLDOMNode,
200 &IID_IHTMLDOMNode2,
201 &IID_IHTMLElement,
202 &IID_IHTMLElement2,
203 &IID_IHTMLElement3,
204 &IID_IHTMLScriptElement,
205 &IID_IDispatchEx,
206 &IID_IConnectionPointContainer,
207 NULL
210 static const IID * const text_iids[] = {
211 &IID_IHTMLDOMNode,
212 &IID_IHTMLDOMNode2,
213 &IID_IHTMLDOMTextNode,
214 NULL
217 static const IID * const location_iids[] = {
218 &IID_IDispatch,
219 &IID_IHTMLLocation,
220 NULL
223 static const IID * const window_iids[] = {
224 &IID_IDispatch,
225 &IID_IHTMLWindow2,
226 &IID_IHTMLWindow3,
227 &IID_IDispatchEx,
228 NULL
231 static const IID * const comment_iids[] = {
232 &IID_IHTMLDOMNode,
233 &IID_IHTMLDOMNode2,
234 &IID_IHTMLElement,
235 &IID_IHTMLElement2,
236 &IID_IHTMLElement3,
237 &IID_IHTMLCommentElement,
238 &IID_IDispatchEx,
239 &IID_IConnectionPointContainer,
240 NULL
243 static const IID * const img_iids[] = {
244 &IID_IHTMLDOMNode,
245 &IID_IHTMLDOMNode2,
246 &IID_IHTMLElement,
247 &IID_IHTMLElement2,
248 &IID_IHTMLElement3,
249 &IID_IDispatchEx,
250 &IID_IHTMLImgElement,
251 &IID_IConnectionPointContainer,
252 NULL
255 static const IID * const tr_iids[] = {
256 &IID_IHTMLDOMNode,
257 &IID_IHTMLDOMNode2,
258 &IID_IHTMLElement,
259 &IID_IHTMLElement2,
260 &IID_IHTMLElement3,
261 &IID_IDispatchEx,
262 &IID_IHTMLTableRow,
263 &IID_IConnectionPointContainer,
264 NULL
267 static const IID * const td_iids[] = {
268 &IID_IHTMLDOMNode,
269 &IID_IHTMLDOMNode2,
270 &IID_IHTMLElement,
271 &IID_IHTMLElement2,
272 &IID_IHTMLElement3,
273 &IID_IDispatchEx,
274 &IID_IConnectionPointContainer,
275 NULL
278 static const IID * const iframe_iids[] = {
279 &IID_IHTMLDOMNode,
280 &IID_IHTMLDOMNode2,
281 &IID_IHTMLElement,
282 &IID_IHTMLElement2,
283 &IID_IHTMLElement3,
284 &IID_IHTMLFrameBase2,
285 &IID_IDispatchEx,
286 &IID_IConnectionPointContainer,
287 NULL
290 static const IID * const generic_iids[] = {
291 &IID_IHTMLDOMNode,
292 &IID_IHTMLDOMNode2,
293 &IID_IHTMLElement,
294 &IID_IHTMLElement2,
295 &IID_IHTMLElement3,
296 &IID_IHTMLGenericElement,
297 &IID_IDispatchEx,
298 &IID_IConnectionPointContainer,
299 NULL
302 static const IID * const style_iids[] = {
303 &IID_IUnknown,
304 &IID_IDispatch,
305 &IID_IDispatchEx,
306 &IID_IHTMLStyle,
307 &IID_IHTMLStyle2,
308 &IID_IHTMLStyle3,
309 &IID_IHTMLStyle4,
310 NULL
313 static const IID * const cstyle_iids[] = {
314 &IID_IUnknown,
315 &IID_IDispatch,
316 &IID_IDispatchEx,
317 &IID_IHTMLCurrentStyle,
318 NULL
321 typedef struct {
322 const char *tag;
323 REFIID *iids;
324 const IID *dispiid;
325 } elem_type_info_t;
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];
357 if(!str)
358 return "(null)";
359 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
360 return buf;
363 static const char *dbgstr_guid(REFIID riid)
365 static char buf[50];
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]);
372 return buf;
375 static int strcmp_wa(LPCWSTR strw, const char *stra)
377 WCHAR buf[512];
378 MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
379 return lstrcmpW(strw, buf);
382 static BSTR a2bstr(const char *str)
384 BSTR ret;
385 int len;
387 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
388 ret = SysAllocStringLen(NULL, len);
389 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
391 return ret;
394 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
396 IUnknown *unk1, *unk2;
398 if(iface1 == iface2)
399 return TRUE;
401 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
402 IUnknown_Release(unk1);
403 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk2);
404 IUnknown_Release(unk2);
406 return unk1 == unk2;
409 static IHTMLDocument2 *create_document(void)
411 IHTMLDocument2 *doc;
412 IHTMLDocument5 *doc5;
413 HRESULT hres;
415 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
416 &IID_IHTMLDocument2, (void**)&doc);
417 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
419 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
420 if(FAILED(hres)) {
421 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
422 IHTMLDocument2_Release(doc);
423 return NULL;
426 IHTMLDocument5_Release(doc5);
427 return doc;
430 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
431 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
433 const IID * const *piid;
434 IUnknown *unk;
435 HRESULT hres;
437 for(piid = iids; *piid; piid++) {
438 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
439 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
440 if(SUCCEEDED(hres))
441 IUnknown_Release(unk);
445 #define test_disp(u,id) _test_disp(__LINE__,u,id)
446 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid)
448 IDispatchEx *dispex;
449 ITypeInfo *typeinfo;
450 UINT ticnt;
451 HRESULT hres;
453 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
454 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
455 if(FAILED(hres))
456 return;
458 ticnt = 0xdeadbeef;
459 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
460 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
461 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
463 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
464 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
466 if(SUCCEEDED(hres)) {
467 TYPEATTR *type_attr;
469 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
470 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
471 ok_(__FILE__,line) (IsEqualGUID(&type_attr->guid, diid), "unexpected guid %s\n", dbgstr_guid(&type_attr->guid));
473 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
474 ITypeInfo_Release(typeinfo);
477 IDispatchEx_Release(dispex);
480 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
481 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
483 IHTMLElement *elem;
484 HRESULT hres;
486 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
487 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
488 return elem;
491 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
492 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
494 IHTMLElement2 *elem;
495 HRESULT hres;
497 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
498 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
499 return elem;
502 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
503 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
505 IHTMLElement3 *elem;
506 HRESULT hres;
508 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
509 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
510 return elem;
513 #define get_node_iface(u) _get_node_iface(__LINE__,u)
514 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
516 IHTMLDOMNode *node;
517 HRESULT hres;
519 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
520 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
521 return node;
524 #define get_img_iface(u) _get_img_iface(__LINE__,u)
525 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
527 IHTMLImgElement *img;
528 HRESULT hres;
530 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
531 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
532 return img;
535 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
536 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
538 IHTMLDOMNode *node = _get_node_iface(line, unk);
539 BSTR name;
540 HRESULT hres;
542 hres = IHTMLDOMNode_get_nodeName(node, &name);
543 IHTMLDOMNode_Release(node);
544 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
545 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", dbgstr_w(name), exname);
547 SysFreeString(name);
550 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
551 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
553 IHTMLElement *elem = _get_elem_iface(line, unk);
554 BSTR tag;
555 HRESULT hres;
557 hres = IHTMLElement_get_tagName(elem, &tag);
558 IHTMLElement_Release(elem);
559 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
560 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", dbgstr_w(tag), extag);
562 SysFreeString(tag);
565 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
566 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
568 _test_elem_tag(line, unk, elem_type_infos[type].tag);
569 _test_ifaces(line, unk, elem_type_infos[type].iids);
571 if(elem_type_infos[type].dispiid)
572 _test_disp(line, unk, elem_type_infos[type].dispiid);
575 #define get_node_type(n) _get_node_type(__LINE__,n)
576 static LONG _get_node_type(unsigned line, IUnknown *unk)
578 IHTMLDOMNode *node = _get_node_iface(line, unk);
579 LONG type = -1;
580 HRESULT hres;
582 hres = IHTMLDOMNode_get_nodeType(node, &type);
583 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
585 IHTMLDOMNode_Release(node);
587 return type;
590 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
591 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
593 IHTMLDOMNode *node = _get_node_iface(line, unk);
594 IHTMLDOMChildrenCollection *col = NULL;
595 IDispatch *disp;
596 HRESULT hres;
598 hres = IHTMLDOMNode_get_childNodes(node, &disp);
599 IHTMLDOMNode_Release(node);
600 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
601 if(FAILED(hres))
602 return NULL;
604 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
605 IDispatch_Release(disp);
606 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
608 return col;
611 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
612 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
614 IHTMLDOMNode *node = NULL;
615 IDispatch *disp;
616 HRESULT hres;
618 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
619 ok(hres == S_OK, "item failed: %08x\n", hres);
621 node = _get_node_iface(line, (IUnknown*)disp);
622 IDispatch_Release(disp);
624 return node;
627 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
628 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
630 VARIANT value;
631 BSTR tmp;
632 HRESULT hres;
634 VariantInit(&value);
636 tmp = a2bstr(name);
637 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
638 SysFreeString(tmp);
639 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
641 if(exval) {
642 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
643 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", dbgstr_w(V_BSTR(&value)));
644 }else {
645 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
648 VariantClear(&value);
651 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
652 static void _test_elem_offset(unsigned line, IUnknown *unk)
654 IHTMLElement *elem = _get_elem_iface(line, unk);
655 LONG l;
656 HRESULT hres;
658 hres = IHTMLElement_get_offsetTop(elem, &l);
659 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
661 hres = IHTMLElement_get_offsetHeight(elem, &l);
662 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
664 hres = IHTMLElement_get_offsetWidth(elem, &l);
665 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
667 IHTMLElement_Release(elem);
670 static void test_doc_elem(IHTMLDocument2 *doc)
672 IHTMLElement *elem;
673 IHTMLDocument3 *doc3;
674 HRESULT hres;
676 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
677 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
679 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
680 IHTMLDocument3_Release(doc3);
681 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
683 test_node_name((IUnknown*)elem, "HTML");
684 test_elem_tag((IUnknown*)elem, "HTML");
686 IHTMLElement_Release(elem);
689 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
690 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
692 IHTMLElement *elem;
693 IHTMLDocument3 *doc3;
694 HRESULT hres;
696 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
697 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
698 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
699 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
700 IHTMLDocument3_Release(doc3);
702 return elem;
705 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
706 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
708 BSTR bstr;
709 HRESULT hres;
711 hres = IHTMLOptionElement_get_text(option, &bstr);
712 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
713 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", dbgstr_w(bstr));
714 SysFreeString(bstr);
717 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
718 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
720 BSTR bstr;
721 HRESULT hres;
723 bstr = a2bstr(text);
724 hres = IHTMLOptionElement_put_text(option, bstr);
725 SysFreeString(bstr);
726 ok(hres == S_OK, "put_text failed: %08x\n", hres);
728 _test_option_text(line, option, text);
731 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
732 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
734 BSTR bstr;
735 HRESULT hres;
737 hres = IHTMLOptionElement_get_value(option, &bstr);
738 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
739 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", dbgstr_w(bstr));
740 SysFreeString(bstr);
743 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
744 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
746 BSTR bstr;
747 HRESULT hres;
749 bstr = a2bstr(value);
750 hres = IHTMLOptionElement_put_value(option, bstr);
751 SysFreeString(bstr);
752 ok(hres == S_OK, "put_value failed: %08x\n", hres);
754 _test_option_value(line, option, value);
757 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
758 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
759 const char *txt, const char *val)
761 IHTMLOptionElementFactory *factory;
762 IHTMLOptionElement *option;
763 IHTMLWindow2 *window;
764 VARIANT text, value, empty;
765 HRESULT hres;
767 hres = IHTMLDocument2_get_parentWindow(doc, &window);
768 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
770 hres = IHTMLWindow2_get_Option(window, &factory);
771 IHTMLWindow2_Release(window);
772 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
774 V_VT(&text) = VT_BSTR;
775 V_BSTR(&text) = a2bstr(txt);
776 V_VT(&value) = VT_BSTR;
777 V_BSTR(&value) = a2bstr(val);
778 V_VT(&empty) = VT_EMPTY;
780 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
781 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
783 IHTMLOptionElementFactory_Release(factory);
784 VariantClear(&text);
785 VariantClear(&value);
787 _test_option_text(line, option, txt);
788 _test_option_value(line, option, val);
790 return option;
793 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
794 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
796 LONG len = 0xdeadbeef;
797 HRESULT hres;
799 hres = IHTMLSelectElement_get_length(select, &len);
800 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
801 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
804 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
805 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
807 LONG idx = 0xdeadbeef;
808 HRESULT hres;
810 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
811 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
812 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
815 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
816 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
818 HRESULT hres;
820 hres = IHTMLSelectElement_put_selectedIndex(select, index);
821 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
822 _test_select_selidx(line, select, index);
825 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
826 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
828 BSTR val;
829 HRESULT hres;
831 hres = IHTMLSelectElement_get_value(select, &val);
832 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
833 if(exval)
834 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", dbgstr_w(val));
835 else
836 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", dbgstr_w(val));
839 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
840 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
842 BSTR bstr;
843 HRESULT hres;
845 bstr = a2bstr(val);
846 hres = IHTMLSelectElement_put_value(select, bstr);
847 SysFreeString(bstr);
848 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
851 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
852 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
854 BSTR type;
855 HRESULT hres;
857 hres = IHTMLSelectElement_get_type(select, &type);
858 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
859 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", dbgstr_w(type), extype);
862 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
863 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
865 BSTR text;
866 HRESULT hres;
868 hres = IHTMLTxtRange_get_text(range, &text);
869 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
871 if(extext) {
872 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
873 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=\"%s\", expected \"%s\"\n", dbgstr_w(text), extext);
874 }else {
875 ok_(__FILE__, line) (text == NULL, "text=\"%s\", expected NULL\n", dbgstr_w(text));
878 SysFreeString(text);
882 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
883 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
885 HRESULT hres;
887 hres = IHTMLTxtRange_collapse(range, b);
888 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
889 _test_range_text(line, range, NULL);
892 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
893 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
894 VARIANT_BOOL exb, const char *extext)
896 VARIANT_BOOL b = 0xe0e0;
897 HRESULT hres;
899 hres = IHTMLTxtRange_expand(range, unit, &b);
900 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
901 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
902 _test_range_text(line, range, extext);
905 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
906 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
908 LONG c = 0xdeadbeef;
909 HRESULT hres;
911 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
912 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
913 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
914 _test_range_text(line, range, NULL);
917 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
918 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
919 LPWSTR unit, LONG cnt, LONG excnt)
921 LONG c = 0xdeadbeef;
922 HRESULT hres;
924 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
925 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
926 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
929 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
930 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
932 LONG c = 0xdeadbeef;
933 HRESULT hres;
935 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
936 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
937 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
940 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
941 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
943 HRESULT hres;
944 BSTR bstr = a2bstr(text);
946 hres = IHTMLTxtRange_put_text(range, bstr);
947 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
948 SysFreeString(bstr);
949 _test_range_text(line, range, NULL);
952 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
953 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
955 VARIANT_BOOL b;
956 HRESULT hres;
958 b = 0xe0e0;
959 hres = IHTMLTxtRange_inRange(range1, range2, &b);
960 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
961 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
964 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
965 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
967 VARIANT_BOOL b;
968 HRESULT hres;
970 b = 0xe0e0;
971 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
972 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
973 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
975 b = 0xe0e0;
976 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
977 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
978 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
980 if(exb) {
981 test_range_inrange(range1, range2, VARIANT_TRUE);
982 test_range_inrange(range2, range1, VARIANT_TRUE);
986 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
987 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
989 IHTMLElement *elem;
990 HRESULT hres;
992 hres = IHTMLTxtRange_parentElement(range, &elem);
993 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
995 _test_elem_type(line, (IUnknown*)elem, type);
997 IHTMLElement_Release(elem);
1000 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1001 static void _test_elem_collection(unsigned line, IUnknown *unk,
1002 const elem_type_t *elem_types, LONG exlen)
1004 IHTMLElementCollection *col;
1005 LONG len;
1006 DWORD i;
1007 VARIANT name, index;
1008 IDispatch *disp;
1009 HRESULT hres;
1011 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1012 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1014 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection);
1016 hres = IHTMLElementCollection_get_length(col, &len);
1017 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1018 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1020 if(len > exlen)
1021 len = exlen;
1023 V_VT(&index) = VT_EMPTY;
1024 V_VT(&name) = VT_I4;
1026 for(i=0; i<len; i++) {
1027 V_I4(&name) = i;
1028 disp = (void*)0xdeadbeef;
1029 hres = IHTMLElementCollection_item(col, name, index, &disp);
1030 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1031 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1032 if(FAILED(hres) || !disp)
1033 continue;
1035 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1036 IDispatch_Release(disp);
1039 V_I4(&name) = len;
1040 disp = (void*)0xdeadbeef;
1041 hres = IHTMLElementCollection_item(col, name, index, &disp);
1042 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1043 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1045 V_I4(&name) = -1;
1046 disp = (void*)0xdeadbeef;
1047 hres = IHTMLElementCollection_item(col, name, index, &disp);
1048 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1049 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1051 IHTMLElementCollection_Release(col);
1054 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1055 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1057 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1058 IHTMLElementCollection *col = NULL;
1059 elem_type_t *types = NULL;
1060 BSTR tmp;
1061 int i;
1062 HRESULT hres;
1064 tmp = a2bstr(elem_type_infos[type].tag);
1065 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1066 SysFreeString(tmp);
1067 IHTMLElement2_Release(elem);
1068 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1069 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1071 if(exlen) {
1072 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1073 for(i=0; i<exlen; i++)
1074 types[i] = type;
1077 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1079 HeapFree(GetProcessHeap(), 0, types);
1082 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1083 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1085 BSTR text = NULL;
1086 HRESULT hres;
1088 hres = IHTMLElement_get_innerText(elem, &text);
1089 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1090 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1091 dbgstr_w(text), extext);
1092 SysFreeString(text);
1095 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1096 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1098 IHTMLDOMChildrenCollection *col;
1099 BSTR str;
1100 HRESULT hres;
1102 str = a2bstr(text);
1103 hres = IHTMLElement_put_innerText(elem, str);
1104 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1105 SysFreeString(str);
1107 _test_elem_innertext(line, elem, text);
1110 col = _get_child_nodes(line, (IUnknown*)elem);
1111 ok(col != NULL, "col == NULL\n");
1112 if(col) {
1113 LONG length = 0, type;
1114 IHTMLDOMNode *node;
1116 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1117 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1118 ok(length == 1, "length = %d\n", length);
1120 node = _get_child_item(line, col, 0);
1121 ok(node != NULL, "node == NULL\n");
1122 if(node) {
1123 type = _get_node_type(line, (IUnknown*)node);
1124 ok(type == 3, "type=%d\n", type);
1125 IHTMLDOMNode_Release(node);
1128 IHTMLDOMChildrenCollection_Release(col);
1133 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1134 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1136 IHTMLElement *elem = _get_elem_iface(line, unk);
1137 BSTR html;
1138 HRESULT hres;
1140 hres = IHTMLElement_get_innerHTML(elem, &html);
1141 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1142 if(inner_html)
1143 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", dbgstr_w(html));
1144 else
1145 ok_(__FILE__,line)(!html, "innerHTML = %s\n", dbgstr_w(html));
1147 IHTMLElement_Release(elem);
1148 SysFreeString(html);
1151 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1152 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1154 IHTMLElement *elem = _get_elem_iface(line, unk);
1155 BSTR html;
1156 HRESULT hres;
1158 html = a2bstr(inner_html);
1159 hres = IHTMLElement_put_innerHTML(elem, html);
1160 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1162 IHTMLElement_Release(elem);
1163 SysFreeString(html);
1166 #define get_first_child(n) _get_first_child(__LINE__,n)
1167 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1169 IHTMLDOMNode *node = _get_node_iface(line, unk);
1170 IHTMLDOMNode *child = NULL;
1171 HRESULT hres;
1173 hres = IHTMLDOMNode_get_firstChild(node, &child);
1174 IHTMLDOMNode_Release(node);
1175 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1177 return child;
1180 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1181 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1183 IHTMLDOMNode *node = _get_node_iface(line, unk);
1184 VARIANT_BOOL b = 0xdead;
1185 HRESULT hres;
1187 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1188 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1189 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1191 IHTMLDOMNode_Release(node);
1194 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1195 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1197 IHTMLDOMNode *node = _get_node_iface(line, unk);
1198 IHTMLDOMNode *parent;
1199 HRESULT hres;
1201 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1202 IHTMLDOMNode_Release(node);
1203 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1205 return parent;
1208 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1209 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1211 IHTMLElement *elem = _get_elem_iface(line, unk);
1212 IHTMLElement *parent;
1213 HRESULT hres;
1215 hres = IHTMLElement_get_parentElement(elem, &parent);
1216 IHTMLElement_Release(elem);
1217 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1219 return parent;
1222 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1223 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1225 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1226 VARIANT_BOOL disabled = 100;
1227 HRESULT hres;
1229 if (!elem3) return;
1230 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1231 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1232 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1233 IHTMLElement3_Release(elem3);
1236 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1237 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1239 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1240 HRESULT hres;
1242 if (!elem3) return;
1243 hres = IHTMLElement3_put_disabled(elem3, b);
1244 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1246 IHTMLElement3_Release(elem3);
1247 _test_elem3_get_disabled(line, unk, b);
1250 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1251 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1253 VARIANT_BOOL disabled = 100;
1254 HRESULT hres;
1256 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1257 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1258 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1260 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1263 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1264 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1266 HRESULT hres;
1268 hres = IHTMLSelectElement_put_disabled(select, b);
1269 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1271 _test_select_get_disabled(line, select, b);
1274 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1275 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1277 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1278 IHTMLTextContainer *txtcont;
1279 LONG l = -1, l2 = -1;
1280 HRESULT hres;
1282 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1283 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1284 IHTMLElement2_Release(elem);
1286 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1287 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1289 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1290 IHTMLTextContainer_Release(txtcont);
1291 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1292 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1294 return l;
1297 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1298 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1300 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1301 IHTMLTextContainer *txtcont;
1302 LONG l = -1, l2 = -1;
1303 HRESULT hres;
1305 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1306 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1307 IHTMLElement2_Release(elem);
1309 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1310 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1312 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1313 IHTMLTextContainer_Release(txtcont);
1314 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1315 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1317 return l;
1320 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1321 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1323 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1324 IHTMLTextContainer *txtcont;
1325 LONG l = -1, l2 = -1;
1326 HRESULT hres;
1328 hres = IHTMLElement2_get_scrollTop(elem, &l);
1329 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1330 IHTMLElement2_Release(elem);
1332 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1333 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1335 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1336 IHTMLTextContainer_Release(txtcont);
1337 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1338 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1340 return l;
1343 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1344 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1346 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1347 IHTMLTextContainer *txtcont;
1348 LONG l = -1, l2 = -1;
1349 HRESULT hres;
1351 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1352 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1354 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1355 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1356 IHTMLElement2_Release(elem);
1358 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1359 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1361 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1362 IHTMLTextContainer_Release(txtcont);
1363 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1364 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1367 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1368 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1370 IHTMLImgElement *img = _get_img_iface(line, unk);
1371 BSTR src;
1372 HRESULT hres;
1374 hres = IHTMLImgElement_get_src(img, &src);
1375 IHTMLImgElement_Release(img);
1376 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1377 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", dbgstr_w(src), exsrc);
1378 SysFreeString(src);
1381 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1382 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1384 IHTMLImgElement *img = _get_img_iface(line, unk);
1385 BSTR tmp;
1386 HRESULT hres;
1388 tmp = a2bstr(src);
1389 hres = IHTMLImgElement_put_src(img, tmp);
1390 IHTMLImgElement_Release(img);
1391 SysFreeString(tmp);
1392 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1394 _test_img_src(line, unk, src);
1397 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1398 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1400 IHTMLImgElement *img = _get_img_iface(line, unk);
1401 BSTR alt;
1402 HRESULT hres;
1404 hres = IHTMLImgElement_get_alt(img, &alt);
1405 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1406 if(exalt)
1407 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", dbgstr_w(alt));
1408 else
1409 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1410 SysFreeString(alt);
1413 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1414 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1416 IHTMLImgElement *img = _get_img_iface(line, unk);
1417 BSTR tmp;
1418 HRESULT hres;
1420 tmp = a2bstr(alt);
1421 hres = IHTMLImgElement_put_alt(img, tmp);
1422 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1423 SysFreeString(tmp);
1425 _test_img_alt(line, unk, alt);
1428 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1429 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1431 VARIANT_BOOL disabled = 100;
1432 HRESULT hres;
1434 hres = IHTMLInputElement_get_disabled(input, &disabled);
1435 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1436 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1438 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1441 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1442 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1444 HRESULT hres;
1446 hres = IHTMLInputElement_put_disabled(input, b);
1447 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1449 _test_input_get_disabled(line, input, b);
1452 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1453 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1455 VARIANT_BOOL checked = 100;
1456 HRESULT hres;
1458 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1459 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1460 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1463 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1464 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1466 HRESULT hres;
1468 hres = IHTMLInputElement_put_defaultChecked(input, b);
1469 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1471 _test_input_get_defaultchecked(line, input, b);
1474 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1475 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1477 VARIANT_BOOL checked = 100;
1478 HRESULT hres;
1480 hres = IHTMLInputElement_get_checked(input, &checked);
1481 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1482 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1485 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1486 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1488 HRESULT hres;
1490 hres = IHTMLInputElement_put_checked(input, b);
1491 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1493 _test_input_get_checked(line, input, b);
1496 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1497 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1499 IHTMLInputElement *input;
1500 BSTR bstr;
1501 HRESULT hres;
1503 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1504 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1505 if(FAILED(hres))
1506 return;
1508 hres = IHTMLInputElement_get_value(input, &bstr);
1509 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1510 if(exval)
1511 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", dbgstr_w(bstr));
1512 else
1513 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1514 SysFreeString(bstr);
1515 IHTMLInputElement_Release(input);
1518 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1519 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1521 IHTMLInputElement *input;
1522 BSTR bstr;
1523 HRESULT hres;
1525 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1526 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1527 if(FAILED(hres))
1528 return;
1530 bstr = a2bstr(val);
1531 hres = IHTMLInputElement_get_value(input, &bstr);
1532 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1533 SysFreeString(bstr);
1534 IHTMLInputElement_Release(input);
1537 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1538 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
1540 IHTMLElement *elem = _get_elem_iface(line, unk);
1541 BSTR class = (void*)0xdeadbeef;
1542 HRESULT hres;
1544 hres = IHTMLElement_get_className(elem, &class);
1545 IHTMLElement_Release(elem);
1546 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
1547 if(exclass)
1548 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", dbgstr_w(class));
1549 else
1550 ok_(__FILE__,line) (!class, "class != NULL\n");
1551 SysFreeString(class);
1554 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1555 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
1557 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1558 short index = -3;
1559 HRESULT hres;
1561 hres = IHTMLElement2_get_tabIndex(elem2, &index);
1562 IHTMLElement2_Release(elem2);
1563 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1564 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
1567 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1568 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
1570 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1571 HRESULT hres;
1573 hres = IHTMLElement2_put_tabIndex(elem2, index);
1574 IHTMLElement2_Release(elem2);
1575 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1577 _test_elem_tabindex(line, unk, index);
1580 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1581 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
1583 IHTMLElement *elem = _get_elem_iface(line, unk);
1584 BSTR tmp;
1585 HRESULT hres;
1587 tmp = class ? a2bstr(class) : NULL;
1588 hres = IHTMLElement_put_className(elem, tmp);
1589 IHTMLElement_Release(elem);
1590 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
1591 SysFreeString(tmp);
1593 _test_elem_class(line, unk, class);
1596 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1597 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
1599 IHTMLElement *elem = _get_elem_iface(line, unk);
1600 BSTR id = (void*)0xdeadbeef;
1601 HRESULT hres;
1603 hres = IHTMLElement_get_id(elem, &id);
1604 IHTMLElement_Release(elem);
1605 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
1607 if(exid)
1608 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", dbgstr_w(id));
1609 else
1610 ok_(__FILE__,line) (!id, "id=%s\n", dbgstr_w(id));
1612 SysFreeString(id);
1615 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1616 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
1618 IHTMLElement *elem = _get_elem_iface(line, unk);
1619 BSTR tmp = a2bstr(new_id);
1620 HRESULT hres;
1622 hres = IHTMLElement_put_id(elem, tmp);
1623 IHTMLElement_Release(elem);
1624 SysFreeString(tmp);
1625 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
1627 _test_elem_id(line, unk, new_id);
1630 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1631 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
1633 IHTMLElement *elem = _get_elem_iface(line, unk);
1634 BSTR title;
1635 HRESULT hres;
1637 hres = IHTMLElement_get_title(elem, &title);
1638 IHTMLElement_Release(elem);
1639 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1640 if(extitle)
1641 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", dbgstr_w(title));
1642 else
1643 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", dbgstr_w(title));
1645 SysFreeString(title);
1648 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1649 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
1651 IHTMLElement *elem = _get_elem_iface(line, unk);
1652 BSTR tmp;
1653 HRESULT hres;
1655 tmp = a2bstr(title);
1656 hres = IHTMLElement_put_title(elem, tmp);
1657 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1659 IHTMLElement_Release(elem);
1660 SysFreeString(tmp);
1663 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1664 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
1666 IHTMLDOMNode *node = _get_node_iface(line, unk);
1667 VARIANT var;
1668 HRESULT hres;
1670 hres = IHTMLDOMNode_get_nodeValue(node, &var);
1671 IHTMLDOMNode_Release(node);
1672 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1674 if(exval) {
1675 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
1676 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", dbgstr_w(V_BSTR(&var)));
1677 }else {
1678 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
1681 VariantClear(&var);
1684 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
1685 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
1687 IHTMLDOMNode *node = _get_node_iface(line, unk);
1688 VARIANT var;
1689 HRESULT hres;
1691 V_VT(&var) = VT_BSTR;
1692 V_BSTR(&var) = a2bstr(val);
1694 hres = IHTMLDOMNode_put_nodeValue(node, var);
1695 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1696 IHTMLDOMNode_Release(node);
1697 VariantClear(&var);
1700 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
1701 static void _test_elem_client_size(unsigned line, IUnknown *unk)
1703 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1704 LONG l;
1705 HRESULT hres;
1707 hres = IHTMLElement2_get_clientWidth(elem, &l);
1708 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
1709 hres = IHTMLElement2_get_clientHeight(elem, &l);
1710 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
1712 IHTMLElement2_Release(elem);
1715 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
1716 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
1718 IHTMLElement *elem = NULL;
1719 BSTR tmp;
1720 HRESULT hres;
1722 tmp = a2bstr(tag);
1723 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
1724 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
1725 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
1727 return elem;
1730 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
1731 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
1733 IHTMLDocument3 *doc3;
1734 IHTMLDOMNode *node = NULL;
1735 BSTR tmp;
1736 HRESULT hres;
1738 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1739 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
1741 tmp = a2bstr(text);
1742 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
1743 IHTMLDocument3_Release(doc3);
1744 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
1745 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
1747 return node;
1750 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
1751 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
1753 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
1754 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
1755 IHTMLDOMNode *new_child = NULL;
1756 HRESULT hres;
1758 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
1759 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
1760 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
1761 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
1763 IHTMLDOMNode_Release(node);
1764 IHTMLDOMNode_Release(child);
1766 return new_child;
1769 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
1770 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
1772 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
1773 IHTMLDOMNode *new_child = NULL;
1774 HRESULT hres;
1776 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
1777 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
1778 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
1779 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
1781 IHTMLDOMNode_Release(node);
1783 return new_child;
1786 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
1787 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
1789 IHTMLDOMNode *node = _get_node_iface(line, unk);
1790 IHTMLDOMNode *new_node = NULL;
1791 HRESULT hres;
1793 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
1794 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
1795 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
1796 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
1798 IHTMLDOMNode_Release(node);
1799 IHTMLDOMNode_Release(new_node);
1802 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
1803 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
1805 BSTR title = NULL;
1806 HRESULT hres;
1808 hres = IHTMLDocument2_get_title(doc, &title);
1809 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1810 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", dbgstr_w(title));
1811 SysFreeString(title);
1814 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
1815 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
1817 BSTR tmp;
1818 HRESULT hres;
1820 tmp = a2bstr(title);
1821 hres = IHTMLDocument2_put_title(doc, tmp);
1822 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1823 SysFreeString(tmp);
1826 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
1827 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
1829 HRESULT hres;
1830 DISPID dispid;
1832 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
1833 LOCALE_USER_DEFAULT, &dispid);
1834 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
1835 if(hres == S_OK)
1837 DISPPARAMS params = {NULL,NULL,0,0};
1838 DISPID dispidNamed = DISPID_PROPERTYPUT;
1839 VARIANT ret;
1840 VARIANT vDefault;
1841 VARIANTARG arg;
1843 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1844 DISPATCH_PROPERTYGET, &params, &vDefault, NULL, NULL);
1845 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
1847 params.cArgs = 1;
1848 params.cNamedArgs = 1;
1849 params.rgdispidNamedArgs = &dispidNamed;
1850 V_VT(&arg) = VT_BSTR;
1851 V_BSTR(&arg) = a2bstr("none");
1852 params.rgvarg = &arg;
1853 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1854 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1855 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
1856 VariantClear(&arg);
1858 V_VT(&arg) = VT_BSTR;
1859 V_BSTR(&arg) = a2bstr("dotted");
1860 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1861 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1862 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
1863 VariantClear(&arg);
1865 V_VT(&arg) = VT_BSTR;
1866 V_BSTR(&arg) = a2bstr("dashed");
1867 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1868 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1869 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
1870 VariantClear(&arg);
1872 V_VT(&arg) = VT_BSTR;
1873 V_BSTR(&arg) = a2bstr("solid");
1874 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1875 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1876 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
1877 VariantClear(&arg);
1879 V_VT(&arg) = VT_BSTR;
1880 V_BSTR(&arg) = a2bstr("double");
1881 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1882 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1883 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
1884 VariantClear(&arg);
1886 V_VT(&arg) = VT_BSTR;
1887 V_BSTR(&arg) = a2bstr("groove");
1888 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1889 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1890 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
1891 VariantClear(&arg);
1893 V_VT(&arg) = VT_BSTR;
1894 V_BSTR(&arg) = a2bstr("ridge");
1895 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1896 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1897 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
1898 VariantClear(&arg);
1900 V_VT(&arg) = VT_BSTR;
1901 V_BSTR(&arg) = a2bstr("inset");
1902 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1903 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1904 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
1905 VariantClear(&arg);
1907 V_VT(&arg) = VT_BSTR;
1908 V_BSTR(&arg) = a2bstr("outset");
1909 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1910 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1911 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
1912 VariantClear(&arg);
1914 V_VT(&arg) = VT_BSTR;
1915 V_BSTR(&arg) = a2bstr("invalid");
1916 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1917 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1918 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
1919 VariantClear(&arg);
1921 params.rgvarg = &vDefault;
1922 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1923 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1924 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
1928 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
1929 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
1931 BSTR text = (void*)0xdeadbeef;
1932 HRESULT hres;
1934 hres = IHTMLStyle_get_cssText(style, &text);
1935 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
1936 if(extext)
1937 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", dbgstr_w(text));
1938 else
1939 ok_(__FILE__,line)(!text, "cssText = %s\n", dbgstr_w(text));
1941 SysFreeString(text);
1944 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
1945 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
1947 BSTR tmp;
1948 HRESULT hres;
1950 tmp = a2bstr(text);
1951 hres = IHTMLStyle_put_cssText(style, tmp);
1952 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
1953 SysFreeString(tmp);
1956 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
1957 const elem_type_t *elem_types, LONG len)
1959 IDispatch *disp;
1960 VARIANT name, index;
1961 DWORD i;
1962 HRESULT hres;
1964 V_VT(&index) = VT_EMPTY;
1965 V_VT(&name) = VT_BSTR;
1966 V_BSTR(&name) = a2bstr(n);
1968 hres = IHTMLElementCollection_item(col, name, index, &disp);
1969 ok(hres == S_OK, "item failed: %08x\n", hres);
1971 test_elem_collection((IUnknown*)disp, elem_types, len);
1972 IDispatch_Release(disp);
1973 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
1974 if(hres != S_OK)
1975 goto cleanup;
1977 V_VT(&index) = VT_I4;
1979 for(i=0; i<len; i++) {
1980 V_I4(&index) = i;
1981 disp = (void*)0xdeadbeef;
1982 hres = IHTMLElementCollection_item(col, name, index, &disp);
1983 ok(hres == S_OK, "item failed: %08x\n", hres);
1984 ok(disp != NULL, "disp == NULL\n");
1985 if(FAILED(hres) || !disp)
1986 continue;
1988 test_elem_type((IUnknown*)disp, elem_types[i]);
1990 IDispatch_Release(disp);
1993 V_I4(&index) = len;
1994 disp = (void*)0xdeadbeef;
1995 hres = IHTMLElementCollection_item(col, name, index, &disp);
1996 ok(hres == S_OK, "item failed: %08x\n", hres);
1997 ok(disp == NULL, "disp != NULL\n");
1999 V_I4(&index) = -1;
2000 disp = (void*)0xdeadbeef;
2001 hres = IHTMLElementCollection_item(col, name, index, &disp);
2002 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2003 ok(disp == NULL, "disp != NULL\n");
2005 cleanup:
2006 SysFreeString(V_BSTR(&name));
2009 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2011 IHTMLElementCollection *col;
2012 IHTMLElement *elem;
2013 IDispatch *disp = (void*)0xdeadbeef;
2014 VARIANT name, index;
2015 HRESULT hres;
2017 hres = IHTMLDocument2_get_all(doc, &col);
2018 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2019 ok(col != NULL, "col == NULL\n");
2020 if(FAILED(hres) || !col)
2021 return NULL;
2023 V_VT(&index) = VT_EMPTY;
2024 V_VT(&name) = VT_BSTR;
2025 V_BSTR(&name) = a2bstr(id);
2027 hres = IHTMLElementCollection_item(col, name, index, &disp);
2028 IHTMLElementCollection_Release(col);
2029 SysFreeString(V_BSTR(&name));
2030 ok(hres == S_OK, "item failed: %08x\n", hres);
2031 if(!expect_success) {
2032 ok(disp == NULL, "disp != NULL\n");
2033 return NULL;
2036 ok(disp != NULL, "disp == NULL\n");
2037 if(!disp)
2038 return NULL;
2040 elem = get_elem_iface((IUnknown*)disp);
2041 IDispatch_Release(disp);
2043 return elem;
2046 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2048 IHTMLDocument3 *doc3;
2049 IHTMLElement *elem;
2050 BSTR tmp;
2051 HRESULT hres;
2053 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2054 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2056 tmp = a2bstr(id);
2057 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2058 SysFreeString(tmp);
2059 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2061 IHTMLDocument3_Release(doc3);
2063 return elem;
2066 static void test_select_elem(IHTMLSelectElement *select)
2068 test_select_type(select, "select-one");
2069 test_select_length(select, 2);
2070 test_select_selidx(select, 0);
2071 test_select_put_selidx(select, 1);
2073 test_select_set_value(select, "val1");
2074 test_select_value(select, "val1");
2076 test_select_get_disabled(select, VARIANT_FALSE);
2077 test_select_set_disabled(select, VARIANT_TRUE);
2078 test_select_set_disabled(select, VARIANT_FALSE);
2081 static void test_create_option_elem(IHTMLDocument2 *doc)
2083 IHTMLOptionElement *option;
2085 option = create_option_elem(doc, "test text", "test value");
2087 test_option_put_text(option, "new text");
2088 test_option_put_value(option, "new value");
2090 IHTMLOptionElement_Release(option);
2093 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2095 IHTMLBodyElement *body;
2096 IHTMLTxtRange *range;
2097 IHTMLElement *elem;
2098 HRESULT hres;
2100 hres = IHTMLDocument2_get_body(doc, &elem);
2101 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2103 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2104 IHTMLElement_Release(elem);
2106 hres = IHTMLBodyElement_createTextRange(body, &range);
2107 IHTMLBodyElement_Release(body);
2108 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2110 return range;
2113 static void test_txtrange(IHTMLDocument2 *doc)
2115 IHTMLTxtRange *body_range, *range, *range2;
2116 IHTMLSelectionObject *selection;
2117 IDispatch *disp_range;
2118 HRESULT hres;
2120 body_range = test_create_body_range(doc);
2122 test_range_text(body_range, "test abc 123\r\nit's text");
2124 hres = IHTMLTxtRange_duplicate(body_range, &range);
2125 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2127 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2128 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2129 test_range_isequal(range, range2, VARIANT_TRUE);
2131 test_range_text(range, "test abc 123\r\nit's text");
2132 test_range_text(body_range, "test abc 123\r\nit's text");
2134 test_range_collapse(range, TRUE);
2135 test_range_isequal(range, range2, VARIANT_FALSE);
2136 test_range_inrange(range, range2, VARIANT_FALSE);
2137 test_range_inrange(range2, range, VARIANT_TRUE);
2138 IHTMLTxtRange_Release(range2);
2140 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2141 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2142 test_range_move(range, characterW, 2, 2);
2143 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2145 test_range_collapse(range, FALSE);
2146 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2148 test_range_collapse(range, FALSE);
2149 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2150 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2151 test_range_move(range, characterW, 2, 2);
2152 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2153 test_range_moveend(range, characterW, -5, -5);
2154 test_range_text(range, NULL);
2155 test_range_moveend(range, characterW, 3, 3);
2156 test_range_text(range, "c 1");
2157 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2158 test_range_collapse(range, TRUE);
2159 test_range_move(range, characterW, 4, 4);
2160 test_range_moveend(range, characterW, 1, 1);
2161 test_range_text(range, " ");
2162 test_range_move(range, wordW, 1, 1);
2163 test_range_moveend(range, characterW, 2, 2);
2164 test_range_text(range, "ab");
2166 IHTMLTxtRange_Release(range);
2168 hres = IHTMLTxtRange_duplicate(body_range, &range);
2169 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2171 test_range_text(range, "test abc 123\r\nit's text");
2172 test_range_move(range, characterW, 3, 3);
2173 test_range_moveend(range, characterW, 1, 1);
2174 test_range_text(range, "t");
2175 test_range_moveend(range, characterW, 3, 3);
2176 test_range_text(range, "t ab");
2177 test_range_moveend(range, characterW, -2, -2);
2178 test_range_text(range, "t ");
2179 test_range_move(range, characterW, 6, 6);
2180 test_range_moveend(range, characterW, 3, 3);
2181 test_range_text(range, "123");
2182 test_range_moveend(range, characterW, 2, 2);
2183 test_range_text(range, "123\r\ni");
2185 IHTMLTxtRange_Release(range);
2187 hres = IHTMLTxtRange_duplicate(body_range, &range);
2188 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2190 test_range_move(range, wordW, 1, 1);
2191 test_range_moveend(range, characterW, 2, 2);
2192 test_range_text(range, "ab");
2194 test_range_move(range, characterW, -2, -2);
2195 test_range_moveend(range, characterW, 2, 2);
2196 test_range_text(range, "t ");
2198 test_range_move(range, wordW, 3, 3);
2199 test_range_move(range, wordW, -2, -2);
2200 test_range_moveend(range, characterW, 2, 2);
2201 test_range_text(range, "ab");
2203 test_range_move(range, characterW, -6, -5);
2204 test_range_moveend(range, characterW, -1, 0);
2205 test_range_moveend(range, characterW, -6, 0);
2206 test_range_move(range, characterW, 2, 2);
2207 test_range_moveend(range, characterW, 2, 2);
2208 test_range_text(range, "st");
2209 test_range_moveend(range, characterW, -6, -4);
2210 test_range_moveend(range, characterW, 2, 2);
2212 IHTMLTxtRange_Release(range);
2214 hres = IHTMLTxtRange_duplicate(body_range, &range);
2215 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2217 test_range_move(range, wordW, 2, 2);
2218 test_range_moveend(range, characterW, 2, 2);
2219 test_range_text(range, "12");
2221 test_range_move(range, characterW, 15, 14);
2222 test_range_move(range, characterW, -2, -2);
2223 test_range_moveend(range, characterW, 3, 2);
2224 test_range_text(range, "t");
2225 test_range_moveend(range, characterW, -1, -1);
2226 test_range_text(range, "t");
2227 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2228 test_range_move(range, characterW, -2, -2);
2229 test_range_moveend(range, characterW, 2, 2);
2230 test_range_text(range, "s ");
2231 test_range_move(range, characterW, 100, 7);
2232 test_range_move(range, wordW, 1, 0);
2233 test_range_move(range, characterW, -2, -2);
2234 test_range_moveend(range, characterW, 3, 2);
2235 test_range_text(range, "t");
2237 IHTMLTxtRange_Release(range);
2239 hres = IHTMLTxtRange_duplicate(body_range, &range);
2240 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2242 test_range_collapse(range, TRUE);
2243 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2244 test_range_put_text(range, "word");
2245 test_range_text(body_range, "wordabc 123\r\nit's text");
2246 test_range_text(range, NULL);
2247 test_range_moveend(range, characterW, 3, 3);
2248 test_range_text(range, "abc");
2249 test_range_movestart(range, characterW, -2, -2);
2250 test_range_text(range, "rdabc");
2251 test_range_movestart(range, characterW, 3, 3);
2252 test_range_text(range, "bc");
2253 test_range_movestart(range, characterW, 4, 4);
2254 test_range_text(range, NULL);
2255 test_range_movestart(range, characterW, -3, -3);
2256 test_range_text(range, "c 1");
2257 test_range_movestart(range, characterW, -7, -6);
2258 test_range_text(range, "wordabc 1");
2259 test_range_movestart(range, characterW, 100, 22);
2260 test_range_text(range, NULL);
2262 IHTMLTxtRange_Release(range);
2263 IHTMLTxtRange_Release(body_range);
2265 hres = IHTMLDocument2_get_selection(doc, &selection);
2266 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2268 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2269 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2270 IHTMLSelectionObject_Release(selection);
2272 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2273 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2274 IDispatch_Release(disp_range);
2276 test_range_text(range, NULL);
2277 test_range_moveend(range, characterW, 3, 3);
2278 test_range_text(range, "wor");
2279 test_range_parent(range, ET_BODY);
2280 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2281 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2282 test_range_move(range, characterW, 3, 3);
2283 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2284 test_range_moveend(range, characterW, -4, -4);
2285 test_range_put_text(range, "abc def ");
2286 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2287 test_range_move(range, wordW, 1, 1);
2288 test_range_movestart(range, characterW, -1, -1);
2289 test_range_text(range, " ");
2290 test_range_move(range, wordW, 1, 1);
2291 test_range_moveend(range, characterW, 3, 3);
2292 test_range_text(range, "def");
2293 test_range_put_text(range, "xyz");
2294 test_range_moveend(range, characterW, 1, 1);
2295 test_range_move(range, wordW, 1, 1);
2296 test_range_moveend(range, characterW, 2, 2);
2297 test_range_text(range, "ab");
2299 IHTMLTxtRange_Release(range);
2302 static void test_txtrange2(IHTMLDocument2 *doc)
2304 IHTMLTxtRange *range;
2306 range = test_create_body_range(doc);
2308 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2309 test_range_move(range, characterW, 5, 5);
2310 test_range_moveend(range, characterW, 1, 1);
2311 test_range_text(range, "2");
2312 test_range_move(range, characterW, -3, -3);
2313 test_range_moveend(range, characterW, 3, 3);
2314 test_range_text(range, "c\r\n\r\n1");
2315 test_range_collapse(range, VARIANT_FALSE);
2316 test_range_moveend(range, characterW, 4, 4);
2317 test_range_text(range, "23");
2318 test_range_moveend(range, characterW, 1, 1);
2319 test_range_text(range, "23\r\n\r\n\r\nd");
2320 test_range_moveend(range, characterW, -1, -1);
2321 test_range_text(range, "23");
2322 test_range_moveend(range, characterW, -1, -1);
2323 test_range_text(range, "23");
2324 test_range_moveend(range, characterW, -2, -2);
2325 test_range_text(range, "2");
2327 IHTMLTxtRange_Release(range);
2330 static void test_compatmode(IHTMLDocument2 *doc)
2332 IHTMLDocument5 *doc5;
2333 BSTR mode;
2334 HRESULT hres;
2336 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2337 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2338 if(FAILED(hres))
2339 return;
2341 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2342 IHTMLDocument5_Release(doc5);
2343 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2344 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", dbgstr_w(mode));
2345 SysFreeString(mode);
2348 static void test_location(IHTMLDocument2 *doc)
2350 IHTMLLocation *location, *location2;
2351 IHTMLWindow2 *window;
2352 ULONG ref;
2353 HRESULT hres;
2355 hres = IHTMLDocument2_get_location(doc, &location);
2356 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2358 hres = IHTMLDocument2_get_location(doc, &location2);
2359 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2361 ok(location == location2, "location != location2\n");
2362 IHTMLLocation_Release(location2);
2364 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2365 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2367 hres = IHTMLWindow2_get_location(window, &location2);
2368 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2369 ok(location == location2, "location != location2\n");
2370 IHTMLLocation_Release(location2);
2372 test_ifaces((IUnknown*)location, location_iids);
2373 test_disp((IUnknown*)location, &IID_IHTMLLocation);
2375 ref = IHTMLLocation_Release(location);
2376 ok(!ref, "location chould be destroyed here\n");
2379 static void test_navigator(IHTMLDocument2 *doc)
2381 IHTMLWindow2 *window;
2382 IOmNavigator *navigator, *navigator2;
2383 ULONG ref;
2384 BSTR bstr;
2385 HRESULT hres;
2387 static const WCHAR v40[] = {'4','.','0'};
2389 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2390 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2392 hres = IHTMLWindow2_get_navigator(window, &navigator);
2393 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2394 ok(navigator != NULL, "navigator == NULL\n");
2395 test_disp((IUnknown*)navigator, &IID_IOmNavigator);
2397 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2398 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2399 ok(navigator != navigator2, "navigator2 != navihgator\n");
2401 IHTMLWindow2_Release(window);
2402 IOmNavigator_Release(navigator2);
2404 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2405 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2406 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", dbgstr_w(bstr));
2407 SysFreeString(bstr);
2409 bstr = NULL;
2410 hres = IOmNavigator_get_platform(navigator, &bstr);
2411 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2412 #ifdef _WIN64
2413 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", dbgstr_w(bstr));
2414 #else
2415 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", dbgstr_w(bstr));
2416 #endif
2417 SysFreeString(bstr);
2419 bstr = NULL;
2420 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2421 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2422 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", dbgstr_w(bstr));
2423 SysFreeString(bstr);
2425 ref = IOmNavigator_Release(navigator);
2426 ok(!ref, "navigator should be destroyed here\n");
2429 static void test_current_style(IHTMLCurrentStyle *current_style)
2431 BSTR str;
2432 HRESULT hres;
2433 VARIANT v;
2435 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle);
2436 test_ifaces((IUnknown*)current_style, cstyle_iids);
2438 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2439 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2440 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", dbgstr_w(str));
2441 SysFreeString(str);
2443 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2444 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2445 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", dbgstr_w(str));
2446 SysFreeString(str);
2448 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
2449 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2450 SysFreeString(str);
2452 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
2453 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
2454 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", dbgstr_w(str));
2455 SysFreeString(str);
2457 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
2458 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
2459 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", dbgstr_w(str));
2460 SysFreeString(str);
2462 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
2463 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2464 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", dbgstr_w(str));
2465 SysFreeString(str);
2467 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
2468 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
2469 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", dbgstr_w(str));
2470 SysFreeString(str);
2472 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
2473 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
2474 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", dbgstr_w(str));
2475 SysFreeString(str);
2477 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
2478 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
2479 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", dbgstr_w(str));
2480 SysFreeString(str);
2482 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
2483 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
2484 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", dbgstr_w(str));
2485 SysFreeString(str);
2487 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
2488 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
2489 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", dbgstr_w(str));
2490 SysFreeString(str);
2492 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
2493 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2494 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", dbgstr_w(str));
2495 SysFreeString(str);
2497 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
2498 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
2499 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", dbgstr_w(str));
2500 SysFreeString(str);
2502 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
2503 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
2504 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", dbgstr_w(str));
2505 SysFreeString(str);
2507 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
2508 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
2509 SysFreeString(str);
2511 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
2512 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
2513 SysFreeString(str);
2515 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
2516 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2517 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2518 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
2519 VariantClear(&v);
2521 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
2522 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
2523 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2524 VariantClear(&v);
2526 hres = IHTMLCurrentStyle_get_left(current_style, &v);
2527 ok(hres == S_OK, "get_left failed: %08x\n", hres);
2528 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2529 VariantClear(&v);
2531 hres = IHTMLCurrentStyle_get_top(current_style, &v);
2532 ok(hres == S_OK, "get_top failed: %08x\n", hres);
2533 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2534 VariantClear(&v);
2536 hres = IHTMLCurrentStyle_get_width(current_style, &v);
2537 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2538 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2539 VariantClear(&v);
2541 hres = IHTMLCurrentStyle_get_height(current_style, &v);
2542 ok(hres == S_OK, "get_height failed: %08x\n", hres);
2543 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2544 VariantClear(&v);
2546 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
2547 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
2548 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2549 VariantClear(&v);
2551 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
2552 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
2553 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2554 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
2555 VariantClear(&v);
2557 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
2558 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
2559 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2560 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", dbgstr_w(V_BSTR(&v)));
2561 VariantClear(&v);
2563 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
2564 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
2565 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2566 VariantClear(&v);
2568 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
2569 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
2570 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2571 VariantClear(&v);
2574 static void test_style2(IHTMLStyle2 *style2)
2576 BSTR str;
2577 HRESULT hres;
2579 str = (void*)0xdeadbeef;
2580 hres = IHTMLStyle2_get_position(style2, &str);
2581 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2582 ok(!str, "str != NULL\n");
2584 str = a2bstr("absolute");
2585 hres = IHTMLStyle2_put_position(style2, str);
2586 ok(hres == S_OK, "put_position failed: %08x\n", hres);
2587 SysFreeString(str);
2589 str = NULL;
2590 hres = IHTMLStyle2_get_position(style2, &str);
2591 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2592 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", dbgstr_w(str));
2593 SysFreeString(str);
2596 static void test_style4(IHTMLStyle4 *style4)
2598 HRESULT hres;
2599 VARIANT v;
2600 VARIANT vdefault;
2602 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
2603 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
2605 V_VT(&v) = VT_BSTR;
2606 V_BSTR(&v) = a2bstr("10px");
2607 hres = IHTMLStyle4_put_minHeight(style4, v);
2608 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
2609 VariantClear(&v);
2611 hres = IHTMLStyle4_get_minHeight(style4, &v);
2612 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
2613 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2614 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", dbgstr_w(V_BSTR(&v)));
2616 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
2617 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
2618 VariantClear(&vdefault);
2621 static void test_default_style(IHTMLStyle *style)
2623 IHTMLStyle2 *style2;
2624 IHTMLStyle4 *style4;
2625 VARIANT_BOOL b;
2626 VARIANT v;
2627 BSTR str;
2628 HRESULT hres;
2629 float f;
2630 BSTR sOverflowDefault;
2631 BSTR sDefault;
2632 VARIANT vDefault;
2634 test_disp((IUnknown*)style, &DIID_DispHTMLStyle);
2635 test_ifaces((IUnknown*)style, style_iids);
2637 test_style_csstext(style, NULL);
2639 hres = IHTMLStyle_get_position(style, &str);
2640 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2641 ok(!str, "str=%s\n", dbgstr_w(str));
2643 V_VT(&v) = VT_NULL;
2644 hres = IHTMLStyle_get_marginRight(style, &v);
2645 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
2646 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
2647 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", dbgstr_w(V_BSTR(&v)));
2649 V_VT(&v) = VT_NULL;
2650 hres = IHTMLStyle_get_marginLeft(style, &v);
2651 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
2652 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
2653 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", dbgstr_w(V_BSTR(&v)));
2655 str = (void*)0xdeadbeef;
2656 hres = IHTMLStyle_get_fontFamily(style, &str);
2657 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2658 ok(!str, "fontFamily = %s\n", dbgstr_w(str));
2660 str = (void*)0xdeadbeef;
2661 hres = IHTMLStyle_get_fontWeight(style, &str);
2662 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2663 ok(!str, "fontWeight = %s\n", dbgstr_w(str));
2665 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
2666 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2668 str = a2bstr("test");
2669 hres = IHTMLStyle_put_fontWeight(style, str);
2670 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
2671 SysFreeString(str);
2673 str = a2bstr("bold");
2674 hres = IHTMLStyle_put_fontWeight(style, str);
2675 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2676 SysFreeString(str);
2678 str = a2bstr("bolder");
2679 hres = IHTMLStyle_put_fontWeight(style, str);
2680 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2681 SysFreeString(str);
2683 str = a2bstr("lighter");
2684 hres = IHTMLStyle_put_fontWeight(style, str);
2685 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2686 SysFreeString(str);
2688 str = a2bstr("100");
2689 hres = IHTMLStyle_put_fontWeight(style, str);
2690 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2691 SysFreeString(str);
2693 str = a2bstr("200");
2694 hres = IHTMLStyle_put_fontWeight(style, str);
2695 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2696 SysFreeString(str);
2698 str = a2bstr("300");
2699 hres = IHTMLStyle_put_fontWeight(style, str);
2700 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2701 SysFreeString(str);
2703 str = a2bstr("400");
2704 hres = IHTMLStyle_put_fontWeight(style, str);
2705 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2706 SysFreeString(str);
2708 str = a2bstr("500");
2709 hres = IHTMLStyle_put_fontWeight(style, str);
2710 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2711 SysFreeString(str);
2713 str = a2bstr("600");
2714 hres = IHTMLStyle_put_fontWeight(style, str);
2715 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2716 SysFreeString(str);
2718 str = a2bstr("700");
2719 hres = IHTMLStyle_put_fontWeight(style, str);
2720 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2721 SysFreeString(str);
2723 str = a2bstr("800");
2724 hres = IHTMLStyle_put_fontWeight(style, str);
2725 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2726 SysFreeString(str);
2728 str = a2bstr("900");
2729 hres = IHTMLStyle_put_fontWeight(style, str);
2730 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2731 SysFreeString(str);
2733 hres = IHTMLStyle_get_fontWeight(style, &str);
2734 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2735 ok(!strcmp_wa(str, "900"), "str != style900\n");
2736 SysFreeString(str);
2738 hres = IHTMLStyle_put_fontWeight(style, sDefault);
2739 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2740 SysFreeString(sDefault);
2742 /* font Variant */
2743 hres = IHTMLStyle_get_fontVariant(style, NULL);
2744 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
2746 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
2747 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2749 str = a2bstr("test");
2750 hres = IHTMLStyle_put_fontVariant(style, str);
2751 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
2752 SysFreeString(str);
2754 str = a2bstr("small-caps");
2755 hres = IHTMLStyle_put_fontVariant(style, str);
2756 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
2757 SysFreeString(str);
2759 str = a2bstr("normal");
2760 hres = IHTMLStyle_put_fontVariant(style, str);
2761 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
2762 SysFreeString(str);
2764 hres = IHTMLStyle_put_fontVariant(style, sDefault);
2765 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
2766 SysFreeString(sDefault);
2768 str = (void*)0xdeadbeef;
2769 hres = IHTMLStyle_get_display(style, &str);
2770 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2771 ok(!str, "display = %s\n", dbgstr_w(str));
2773 str = (void*)0xdeadbeef;
2774 hres = IHTMLStyle_get_visibility(style, &str);
2775 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
2776 ok(!str, "visibility = %s\n", dbgstr_w(str));
2778 V_VT(&v) = VT_NULL;
2779 hres = IHTMLStyle_get_fontSize(style, &v);
2780 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
2781 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
2782 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", dbgstr_w(V_BSTR(&v)));
2784 V_VT(&v) = VT_NULL;
2785 hres = IHTMLStyle_get_color(style, &v);
2786 ok(hres == S_OK, "get_color failed: %08x\n", hres);
2787 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
2788 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", dbgstr_w(V_BSTR(&v)));
2790 b = 0xfefe;
2791 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
2792 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
2793 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
2795 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
2796 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
2797 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
2799 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
2800 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
2801 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
2803 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
2804 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
2806 b = 0xfefe;
2807 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
2808 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
2809 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
2811 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
2812 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
2813 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
2815 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
2816 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
2817 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
2819 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
2820 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
2822 b = 0xfefe;
2823 hres = IHTMLStyle_get_textDecorationNone(style, &b);
2824 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
2825 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
2827 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
2828 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
2829 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
2831 hres = IHTMLStyle_get_textDecorationNone(style, &b);
2832 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
2833 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
2835 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
2836 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
2838 b = 0xfefe;
2839 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
2840 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
2841 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
2843 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
2844 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
2845 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
2847 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
2848 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
2849 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
2851 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
2852 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
2854 b = 0xfefe;
2855 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
2856 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
2857 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
2859 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
2860 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
2861 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
2863 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
2864 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
2865 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
2867 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
2868 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
2870 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
2871 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2873 str = a2bstr("invalid");
2874 hres = IHTMLStyle_put_textDecoration(style, str);
2875 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
2876 SysFreeString(str);
2878 str = a2bstr("none");
2879 hres = IHTMLStyle_put_textDecoration(style, str);
2880 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2881 SysFreeString(str);
2883 str = a2bstr("underline");
2884 hres = IHTMLStyle_put_textDecoration(style, str);
2885 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2886 SysFreeString(str);
2888 str = a2bstr("overline");
2889 hres = IHTMLStyle_put_textDecoration(style, str);
2890 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2891 SysFreeString(str);
2893 str = a2bstr("line-through");
2894 hres = IHTMLStyle_put_textDecoration(style, str);
2895 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2896 SysFreeString(str);
2898 str = a2bstr("blink");
2899 hres = IHTMLStyle_put_textDecoration(style, str);
2900 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2901 SysFreeString(str);
2903 hres = IHTMLStyle_get_textDecoration(style, &str);
2904 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2905 ok(!strcmp_wa(str, "blink"), "str != blink\n");
2906 SysFreeString(str);
2908 hres = IHTMLStyle_put_textDecoration(style, sDefault);
2909 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2910 SysFreeString(sDefault);
2912 hres = IHTMLStyle_get_posWidth(style, NULL);
2913 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
2915 hres = IHTMLStyle_get_posWidth(style, &f);
2916 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
2917 ok(f == 0.0f, "f = %f\n", f);
2919 V_VT(&v) = VT_EMPTY;
2920 hres = IHTMLStyle_get_width(style, &v);
2921 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2922 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
2923 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
2925 hres = IHTMLStyle_put_posWidth(style, 2.2);
2926 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
2928 hres = IHTMLStyle_get_posWidth(style, &f);
2929 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
2930 ok(f == 2.0f ||
2931 f == 2.2f, /* IE8 */
2932 "f = %f\n", f);
2934 V_VT(&v) = VT_BSTR;
2935 V_BSTR(&v) = a2bstr("auto");
2936 hres = IHTMLStyle_put_width(style, v);
2937 ok(hres == S_OK, "put_width failed: %08x\n", hres);
2938 VariantClear(&v);
2940 V_VT(&v) = VT_EMPTY;
2941 hres = IHTMLStyle_get_width(style, &v);
2942 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2943 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
2944 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", dbgstr_w(V_BSTR(&v)));
2945 VariantClear(&v);
2947 /* margin tests */
2948 str = (void*)0xdeadbeef;
2949 hres = IHTMLStyle_get_margin(style, &str);
2950 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
2951 ok(!str, "margin = %s\n", dbgstr_w(str));
2953 str = a2bstr("1");
2954 hres = IHTMLStyle_put_margin(style, str);
2955 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
2956 SysFreeString(str);
2958 hres = IHTMLStyle_get_margin(style, &str);
2959 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
2960 ok(strcmp_wa(str, "1"), "margin = %s\n", dbgstr_w(str));
2962 hres = IHTMLStyle_put_margin(style, NULL);
2963 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
2965 str = NULL;
2966 hres = IHTMLStyle_get_border(style, &str);
2967 ok(hres == S_OK, "get_border failed: %08x\n", hres);
2968 ok(!str || !*str, "str is not empty\n");
2969 SysFreeString(str);
2971 str = a2bstr("1px");
2972 hres = IHTMLStyle_put_border(style, str);
2973 ok(hres == S_OK, "put_border failed: %08x\n", hres);
2974 SysFreeString(str);
2976 V_VT(&v) = VT_EMPTY;
2977 hres = IHTMLStyle_get_left(style, &v);
2978 ok(hres == S_OK, "get_left failed: %08x\n", hres);
2979 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
2980 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
2981 VariantClear(&v);
2983 /* Test posLeft */
2984 hres = IHTMLStyle_get_posLeft(style, NULL);
2985 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
2987 f = 1.0f;
2988 hres = IHTMLStyle_get_posLeft(style, &f);
2989 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
2990 ok(f == 0.0, "expected 0.0 got %f\n", f);
2992 hres = IHTMLStyle_put_posLeft(style, 4.9f);
2993 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
2995 hres = IHTMLStyle_get_posLeft(style, &f);
2996 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
2997 ok(f == 4.0 ||
2998 f == 4.9f, /* IE8 */
2999 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3001 /* Ensure left is updated correctly. */
3002 V_VT(&v) = VT_EMPTY;
3003 hres = IHTMLStyle_get_left(style, &v);
3004 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3005 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3006 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3007 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3008 "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
3009 VariantClear(&v);
3011 /* Test left */
3012 V_VT(&v) = VT_BSTR;
3013 V_BSTR(&v) = a2bstr("3px");
3014 hres = IHTMLStyle_put_left(style, v);
3015 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3016 VariantClear(&v);
3018 hres = IHTMLStyle_get_posLeft(style, &f);
3019 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3020 ok(f == 3.0, "expected 3.0 got %f\n", f);
3022 V_VT(&v) = VT_EMPTY;
3023 hres = IHTMLStyle_get_left(style, &v);
3024 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3025 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3026 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
3027 VariantClear(&v);
3029 V_VT(&v) = VT_NULL;
3030 hres = IHTMLStyle_put_left(style, v);
3031 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3033 V_VT(&v) = VT_EMPTY;
3034 hres = IHTMLStyle_get_left(style, &v);
3035 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3036 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3037 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3038 VariantClear(&v);
3040 V_VT(&v) = VT_EMPTY;
3041 hres = IHTMLStyle_get_top(style, &v);
3042 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3043 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3044 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3045 VariantClear(&v);
3047 /* Test posTop */
3048 hres = IHTMLStyle_get_posTop(style, NULL);
3049 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3051 f = 1.0f;
3052 hres = IHTMLStyle_get_posTop(style, &f);
3053 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3054 ok(f == 0.0, "expected 0.0 got %f\n", f);
3056 hres = IHTMLStyle_put_posTop(style, 4.9f);
3057 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3059 hres = IHTMLStyle_get_posTop(style, &f);
3060 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3061 ok(f == 4.0 ||
3062 f == 4.9f, /* IE8 */
3063 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3065 V_VT(&v) = VT_BSTR;
3066 V_BSTR(&v) = a2bstr("3px");
3067 hres = IHTMLStyle_put_top(style, v);
3068 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3069 VariantClear(&v);
3071 V_VT(&v) = VT_EMPTY;
3072 hres = IHTMLStyle_get_top(style, &v);
3073 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3074 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3075 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
3076 VariantClear(&v);
3078 hres = IHTMLStyle_get_posTop(style, &f);
3079 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3080 ok(f == 3.0, "expected 3.0 got %f\n", f);
3082 V_VT(&v) = VT_NULL;
3083 hres = IHTMLStyle_put_top(style, v);
3084 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3086 V_VT(&v) = VT_EMPTY;
3087 hres = IHTMLStyle_get_top(style, &v);
3088 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3089 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3090 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3091 VariantClear(&v);
3093 /* Test posHeight */
3094 hres = IHTMLStyle_get_posHeight(style, NULL);
3095 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3097 V_VT(&v) = VT_EMPTY;
3098 hres = IHTMLStyle_get_height(style, &v);
3099 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3100 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3101 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3102 VariantClear(&v);
3104 f = 1.0f;
3105 hres = IHTMLStyle_get_posHeight(style, &f);
3106 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3107 ok(f == 0.0, "expected 0.0 got %f\n", f);
3109 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3110 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3112 hres = IHTMLStyle_get_posHeight(style, &f);
3113 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3114 ok(f == 4.0 ||
3115 f == 4.9f, /* IE8 */
3116 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3118 V_VT(&v) = VT_BSTR;
3119 V_BSTR(&v) = a2bstr("64px");
3120 hres = IHTMLStyle_put_height(style, v);
3121 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3122 VariantClear(&v);
3124 V_VT(&v) = VT_EMPTY;
3125 hres = IHTMLStyle_get_height(style, &v);
3126 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3127 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3128 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
3129 VariantClear(&v);
3131 hres = IHTMLStyle_get_posHeight(style, &f);
3132 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3133 ok(f == 64.0, "expected 64.0 got %f\n", f);
3135 str = (void*)0xdeadbeef;
3136 hres = IHTMLStyle_get_cursor(style, &str);
3137 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3138 ok(!str, "get_cursor != NULL\n");
3139 SysFreeString(str);
3141 str = a2bstr("default");
3142 hres = IHTMLStyle_put_cursor(style, str);
3143 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3144 SysFreeString(str);
3146 str = NULL;
3147 hres = IHTMLStyle_get_cursor(style, &str);
3148 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3149 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", dbgstr_w(str));
3150 SysFreeString(str);
3152 V_VT(&v) = VT_EMPTY;
3153 hres = IHTMLStyle_get_verticalAlign(style, &v);
3154 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3155 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3156 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3157 VariantClear(&v);
3159 V_VT(&v) = VT_BSTR;
3160 V_BSTR(&v) = a2bstr("middle");
3161 hres = IHTMLStyle_put_verticalAlign(style, v);
3162 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3163 VariantClear(&v);
3165 V_VT(&v) = VT_EMPTY;
3166 hres = IHTMLStyle_get_verticalAlign(style, &v);
3167 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3168 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3169 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
3170 VariantClear(&v);
3172 str = (void*)0xdeadbeef;
3173 hres = IHTMLStyle_get_textAlign(style, &str);
3174 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3175 ok(!str, "textAlign != NULL\n");
3177 str = a2bstr("center");
3178 hres = IHTMLStyle_put_textAlign(style, str);
3179 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3180 SysFreeString(str);
3182 str = NULL;
3183 hres = IHTMLStyle_get_textAlign(style, &str);
3184 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3185 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", dbgstr_w(V_BSTR(&v)));
3186 SysFreeString(str);
3188 str = (void*)0xdeadbeef;
3189 hres = IHTMLStyle_get_filter(style, &str);
3190 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3191 ok(!str, "filter != NULL\n");
3193 str = a2bstr("alpha(opacity=100)");
3194 hres = IHTMLStyle_put_filter(style, str);
3195 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3196 SysFreeString(str);
3198 V_VT(&v) = VT_EMPTY;
3199 hres = IHTMLStyle_get_zIndex(style, &v);
3200 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3201 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3202 ok(!V_I4(&v), "V_I4(v) != 0\n");
3203 VariantClear(&v);
3205 V_VT(&v) = VT_BSTR;
3206 V_BSTR(&v) = a2bstr("1");
3207 hres = IHTMLStyle_put_zIndex(style, v);
3208 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3209 VariantClear(&v);
3211 V_VT(&v) = VT_EMPTY;
3212 hres = IHTMLStyle_get_zIndex(style, &v);
3213 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3214 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3215 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3216 VariantClear(&v);
3218 /* fontStyle */
3219 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3220 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3222 str = a2bstr("test");
3223 hres = IHTMLStyle_put_fontStyle(style, str);
3224 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3225 SysFreeString(str);
3227 str = a2bstr("italic");
3228 hres = IHTMLStyle_put_fontStyle(style, str);
3229 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3230 SysFreeString(str);
3232 str = a2bstr("oblique");
3233 hres = IHTMLStyle_put_fontStyle(style, str);
3234 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3235 SysFreeString(str);
3237 str = a2bstr("normal");
3238 hres = IHTMLStyle_put_fontStyle(style, str);
3239 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3240 SysFreeString(str);
3242 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3243 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3244 SysFreeString(sDefault);
3246 /* overflow */
3247 hres = IHTMLStyle_get_overflow(style, NULL);
3248 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3250 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3251 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3253 str = a2bstr("test");
3254 hres = IHTMLStyle_put_overflow(style, str);
3255 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
3256 SysFreeString(str);
3258 str = a2bstr("visible");
3259 hres = IHTMLStyle_put_overflow(style, str);
3260 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3261 SysFreeString(str);
3263 str = a2bstr("scroll");
3264 hres = IHTMLStyle_put_overflow(style, str);
3265 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3266 SysFreeString(str);
3268 str = a2bstr("hidden");
3269 hres = IHTMLStyle_put_overflow(style, str);
3270 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3271 SysFreeString(str);
3273 str = a2bstr("auto");
3274 hres = IHTMLStyle_put_overflow(style, str);
3275 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3276 SysFreeString(str);
3278 hres = IHTMLStyle_get_overflow(style, &str);
3279 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3280 ok(!strcmp_wa(str, "auto"), "str=%s\n", dbgstr_w(str));
3281 SysFreeString(str);
3283 /* restore overflow default */
3284 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
3285 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3286 SysFreeString(sOverflowDefault);
3288 /* Attribute Tests*/
3289 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
3290 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3292 str = a2bstr("position");
3293 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
3294 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3296 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3297 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3298 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3299 VariantClear(&v);
3301 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
3302 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
3304 V_VT(&v) = VT_BSTR;
3305 V_BSTR(&v) = a2bstr("absolute");
3306 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3307 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3308 VariantClear(&v);
3310 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3311 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3312 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3313 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", dbgstr_w(V_BSTR(&v)));
3314 VariantClear(&v);
3316 V_VT(&v) = VT_BSTR;
3317 V_BSTR(&v) = NULL;
3318 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3319 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3320 VariantClear(&v);
3322 SysFreeString(str);
3324 str = a2bstr("borderLeftStyle");
3325 test_border_styles(style, str);
3326 SysFreeString(str);
3328 str = a2bstr("borderbottomstyle");
3329 test_border_styles(style, str);
3330 SysFreeString(str);
3332 str = a2bstr("borderrightstyle");
3333 test_border_styles(style, str);
3334 SysFreeString(str);
3336 str = a2bstr("bordertopstyle");
3337 test_border_styles(style, str);
3338 SysFreeString(str);
3340 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
3341 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3343 str = a2bstr("none dotted dashed solid");
3344 hres = IHTMLStyle_put_borderStyle(style, str);
3345 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3346 SysFreeString(str);
3348 str = a2bstr("none dotted dashed solid");
3349 hres = IHTMLStyle_get_borderStyle(style, &str);
3350 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3351 ok(!strcmp_wa(str, "none dotted dashed solid"),
3352 "expected (none dotted dashed solid) = (%s)\n", dbgstr_w(V_BSTR(&v)));
3353 SysFreeString(str);
3355 str = a2bstr("double groove ridge inset");
3356 hres = IHTMLStyle_put_borderStyle(style, str);
3357 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3358 SysFreeString(str);
3360 str = a2bstr("window-inset outset ridge inset");
3361 hres = IHTMLStyle_put_borderStyle(style, str);
3362 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3363 SysFreeString(str);
3365 str = a2bstr("window-inset");
3366 hres = IHTMLStyle_put_borderStyle(style, str);
3367 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3368 SysFreeString(str);
3370 str = a2bstr("none none none none none");
3371 hres = IHTMLStyle_put_borderStyle(style, str);
3372 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3373 SysFreeString(str);
3375 str = a2bstr("invalid none none none");
3376 hres = IHTMLStyle_put_borderStyle(style, str);
3377 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3378 SysFreeString(str);
3380 str = a2bstr("none invalid none none");
3381 hres = IHTMLStyle_put_borderStyle(style, str);
3382 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3383 SysFreeString(str);
3385 hres = IHTMLStyle_put_borderStyle(style, sDefault);
3386 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3387 SysFreeString(sDefault);
3389 /* backgoundColor */
3390 hres = IHTMLStyle_get_backgroundColor(style, &v);
3391 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
3392 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3393 ok(!V_BSTR(&v), "str=%s\n", dbgstr_w(V_BSTR(&v)));
3394 VariantClear(&v);
3396 /* PaddingLeft */
3397 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
3398 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3400 V_VT(&v) = VT_BSTR;
3401 V_BSTR(&v) = a2bstr("10");
3402 hres = IHTMLStyle_put_paddingLeft(style, v);
3403 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3404 VariantClear(&v);
3406 hres = IHTMLStyle_get_paddingLeft(style, &v);
3407 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3408 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", dbgstr_w(V_BSTR(&v)));
3410 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
3411 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3413 /* BackgroundRepeat */
3414 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
3415 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3417 str = a2bstr("invalid");
3418 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3419 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
3420 SysFreeString(str);
3422 str = a2bstr("repeat");
3423 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3424 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3425 SysFreeString(str);
3427 str = a2bstr("no-repeat");
3428 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3429 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3430 SysFreeString(str);
3432 str = a2bstr("repeat-x");
3433 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3434 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3435 SysFreeString(str);
3437 str = a2bstr("repeat-y");
3438 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3439 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3440 SysFreeString(str);
3442 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
3443 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3444 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", dbgstr_w(str));
3445 SysFreeString(str);
3447 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
3448 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3449 SysFreeString(sDefault);
3451 /* BorderColor */
3452 hres = IHTMLStyle_get_borderColor(style, &sDefault);
3453 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3455 str = a2bstr("red green red blue");
3456 hres = IHTMLStyle_put_borderColor(style, str);
3457 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3458 SysFreeString(str);
3460 hres = IHTMLStyle_get_borderColor(style, &str);
3461 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3462 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", dbgstr_w(str));
3463 SysFreeString(str);
3465 hres = IHTMLStyle_put_borderColor(style, sDefault);
3466 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3467 SysFreeString(sDefault);
3469 /* BorderLeft */
3470 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
3471 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
3473 str = a2bstr("thick dotted red");
3474 hres = IHTMLStyle_put_borderLeft(style, str);
3475 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3476 SysFreeString(str);
3478 /* IHTMLStyle_get_borderLeft appears to have a bug where
3479 it returns the first letter of the color. So we check
3480 each style individually.
3482 V_BSTR(&v) = NULL;
3483 hres = IHTMLStyle_get_borderLeftColor(style, &v);
3484 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3485 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", dbgstr_w(V_BSTR(&v)));
3486 VariantClear(&v);
3488 V_BSTR(&v) = NULL;
3489 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
3490 todo_wine ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3491 todo_wine ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", dbgstr_w(V_BSTR(&v)));
3492 VariantClear(&v);
3494 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
3495 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3496 ok(!strcmp_wa(str, "dotted"), "str=%s\n", dbgstr_w(str));
3497 SysFreeString(str);
3499 hres = IHTMLStyle_put_borderLeft(style, sDefault);
3500 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3501 SysFreeString(sDefault);
3503 /* backgroundPositionX */
3504 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
3505 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3507 V_VT(&v) = VT_BSTR;
3508 V_BSTR(&v) = a2bstr("10px");
3509 hres = IHTMLStyle_put_backgroundPositionX(style, v);
3510 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3511 VariantClear(&v);
3513 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
3514 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3515 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3516 VariantClear(&v);
3518 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
3519 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3520 VariantClear(&vDefault);
3522 /* backgroundPositionY */
3523 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
3524 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
3526 V_VT(&v) = VT_BSTR;
3527 V_BSTR(&v) = a2bstr("10px");
3528 hres = IHTMLStyle_put_backgroundPositionY(style, v);
3529 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
3530 VariantClear(&v);
3532 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
3533 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
3534 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3535 VariantClear(&v);
3537 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
3538 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
3539 VariantClear(&vDefault);
3541 /* borderTopWidth */
3542 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
3543 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
3545 V_VT(&v) = VT_BSTR;
3546 V_BSTR(&v) = a2bstr("10px");
3547 hres = IHTMLStyle_put_borderTopWidth(style, v);
3548 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
3549 VariantClear(&v);
3551 hres = IHTMLStyle_get_borderTopWidth(style, &v);
3552 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
3553 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", dbgstr_w(V_BSTR(&v)));
3554 VariantClear(&v);
3556 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
3557 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
3558 VariantClear(&vDefault);
3560 /* borderRightWidth */
3561 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
3562 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
3564 V_VT(&v) = VT_BSTR;
3565 V_BSTR(&v) = a2bstr("10");
3566 hres = IHTMLStyle_put_borderRightWidth(style, v);
3567 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
3568 VariantClear(&v);
3570 hres = IHTMLStyle_get_borderRightWidth(style, &v);
3571 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
3572 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", dbgstr_w(V_BSTR(&v)));
3573 VariantClear(&v);
3575 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
3576 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
3577 VariantClear(&vDefault);
3579 /* borderBottomWidth */
3580 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
3581 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
3583 V_VT(&v) = VT_BSTR;
3584 V_BSTR(&v) = a2bstr("10");
3585 hres = IHTMLStyle_put_borderBottomWidth(style, v);
3586 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
3587 VariantClear(&v);
3589 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
3590 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
3591 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", dbgstr_w(V_BSTR(&v)));
3592 VariantClear(&v);
3594 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
3595 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
3596 VariantClear(&vDefault);
3598 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
3599 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
3600 if(SUCCEEDED(hres)) {
3601 test_style2(style2);
3602 IHTMLStyle2_Release(style2);
3605 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
3606 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
3607 if(SUCCEEDED(hres)) {
3608 test_style4(style4);
3609 IHTMLStyle4_Release(style4);
3613 static void test_set_csstext(IHTMLStyle *style)
3615 VARIANT v;
3616 HRESULT hres;
3618 test_style_set_csstext(style, "background-color: black;");
3620 hres = IHTMLStyle_get_backgroundColor(style, &v);
3621 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
3622 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3623 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", dbgstr_w(V_BSTR(&v)));
3624 VariantClear(&v);
3627 static void test_default_selection(IHTMLDocument2 *doc)
3629 IHTMLSelectionObject *selection;
3630 IHTMLTxtRange *range;
3631 IDispatch *disp;
3632 BSTR str;
3633 HRESULT hres;
3635 hres = IHTMLDocument2_get_selection(doc, &selection);
3636 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
3638 hres = IHTMLSelectionObject_get_type(selection, &str);
3639 ok(hres == S_OK, "get_type failed: %08x\n", hres);
3640 ok(!lstrcmpW(str, noneW), "type = %s\n", dbgstr_w(str));
3641 SysFreeString(str);
3643 hres = IHTMLSelectionObject_createRange(selection, &disp);
3644 IHTMLSelectionObject_Release(selection);
3645 ok(hres == S_OK, "createRange failed: %08x\n", hres);
3647 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
3648 IDispatch_Release(disp);
3649 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
3651 test_range_text(range, NULL);
3652 IHTMLTxtRange_Release(range);
3655 static void test_default_body(IHTMLBodyElement *body)
3657 LONG l;
3658 BSTR bstr;
3659 HRESULT hres;
3660 VARIANT v;
3661 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
3662 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
3663 WCHAR sResInvalid[] = {'#','0','0','a','0','d','0',0};
3665 bstr = (void*)0xdeadbeef;
3666 hres = IHTMLBodyElement_get_background(body, &bstr);
3667 ok(hres == S_OK, "get_background failed: %08x\n", hres);
3668 ok(bstr == NULL, "bstr != NULL\n");
3670 l = elem_get_scroll_height((IUnknown*)body);
3671 ok(l != -1, "scrollHeight == -1\n");
3672 l = elem_get_scroll_width((IUnknown*)body);
3673 ok(l != -1, "scrollWidth == -1\n");
3674 l = elem_get_scroll_top((IUnknown*)body);
3675 ok(!l, "scrollTop = %d\n", l);
3676 elem_get_scroll_left((IUnknown*)body);
3678 /* get_text tests */
3679 hres = IHTMLBodyElement_get_text(body, &v);
3680 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
3681 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
3682 ok(bstr == NULL, "bstr != NULL\n");
3685 /* get_text - Invalid Text */
3686 V_VT(&v) = VT_BSTR;
3687 V_BSTR(&v) = SysAllocString(sTextInvalid);
3688 hres = IHTMLBodyElement_put_text(body, v);
3689 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
3691 V_VT(&v) = VT_NULL;
3692 hres = IHTMLBodyElement_get_text(body, &v);
3693 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
3694 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
3695 ok(!lstrcmpW(sResInvalid, V_BSTR(&v)), "bstr != sResInvalid\n");
3696 VariantClear(&v);
3698 /* get_text - Valid Text */
3699 V_VT(&v) = VT_BSTR;
3700 V_BSTR(&v) = SysAllocString(sBodyText);
3701 hres = IHTMLBodyElement_put_text(body, v);
3702 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
3704 V_VT(&v) = VT_NULL;
3705 hres = IHTMLBodyElement_get_text(body, &v);
3706 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
3707 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
3708 ok(lstrcmpW(bstr, V_BSTR(&v)), "bstr != V_BSTR(&v)\n");
3709 VariantClear(&v);
3712 static void test_body_funs(IHTMLBodyElement *body)
3714 static WCHAR sRed[] = {'r','e','d',0};
3715 static WCHAR sRedbg[] = {'#','f','f','0','0','0','0',0};
3716 VARIANT vbg;
3717 VARIANT vDefaultbg;
3718 HRESULT hres;
3720 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
3721 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
3722 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
3724 V_VT(&vbg) = VT_BSTR;
3725 V_BSTR(&vbg) = SysAllocString(sRed);
3726 hres = IHTMLBodyElement_put_bgColor(body, vbg);
3727 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
3728 VariantClear(&vbg);
3730 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
3731 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
3732 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
3733 ok(!lstrcmpW(V_BSTR(&vbg), sRedbg), "Unexpected type %s\n", dbgstr_w(V_BSTR(&vbg)));
3734 VariantClear(&vbg);
3736 /* Restore Originial */
3737 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
3738 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
3739 VariantClear(&vDefaultbg);
3742 static void test_window(IHTMLDocument2 *doc)
3744 IHTMLWindow2 *window, *window2, *self;
3745 IHTMLDocument2 *doc2 = NULL;
3746 IDispatch *disp;
3747 HRESULT hres;
3749 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3750 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3751 test_ifaces((IUnknown*)window, window_iids);
3752 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2);
3754 hres = IHTMLWindow2_get_document(window, &doc2);
3755 ok(hres == S_OK, "get_document failed: %08x\n", hres);
3756 ok(doc2 != NULL, "doc2 == NULL\n");
3758 IHTMLDocument_Release(doc2);
3760 hres = IHTMLWindow2_get_window(window, &window2);
3761 ok(hres == S_OK, "get_window failed: %08x\n", hres);
3762 ok(window2 != NULL, "window2 == NULL\n");
3764 hres = IHTMLWindow2_get_self(window, &self);
3765 ok(hres == S_OK, "get_self failed: %08x\n", hres);
3766 ok(window2 != NULL, "self == NULL\n");
3768 ok(self == window2, "self != window2\n");
3770 IHTMLWindow2_Release(window2);
3771 IHTMLWindow2_Release(self);
3773 disp = NULL;
3774 hres = IHTMLDocument2_get_Script(doc, &disp);
3775 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
3776 ok(disp == (void*)window, "disp != window\n");
3777 IDispatch_Release(disp);
3779 IHTMLWindow2_Release(window);
3782 static void test_defaults(IHTMLDocument2 *doc)
3784 IHTMLStyleSheetsCollection *stylesheetcol;
3785 IHTMLCurrentStyle *cstyle;
3786 IHTMLBodyElement *body;
3787 IHTMLElement2 *elem2;
3788 IHTMLElement *elem;
3789 IHTMLStyle *style;
3790 LONG l;
3791 HRESULT hres;
3792 IHTMLElementCollection *collection;
3794 hres = IHTMLDocument2_get_body(doc, &elem);
3795 ok(hres == S_OK, "get_body failed: %08x\n", hres);
3797 hres = IHTMLDocument2_get_images(doc, NULL);
3798 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
3800 hres = IHTMLDocument2_get_images(doc, &collection);
3801 ok(hres == S_OK, "get_images failed: %08x\n", hres);
3802 if(hres == S_OK)
3804 test_elem_collection((IUnknown*)collection, NULL, 0);
3805 IHTMLElementCollection_Release(collection);
3808 hres = IHTMLDocument2_get_applets(doc, NULL);
3809 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
3811 hres = IHTMLDocument2_get_applets(doc, &collection);
3812 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
3813 if(hres == S_OK)
3815 test_elem_collection((IUnknown*)collection, NULL, 0);
3816 IHTMLElementCollection_Release(collection);
3819 hres = IHTMLDocument2_get_links(doc, NULL);
3820 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
3822 hres = IHTMLDocument2_get_links(doc, &collection);
3823 ok(hres == S_OK, "get_links failed: %08x\n", hres);
3824 if(hres == S_OK)
3826 test_elem_collection((IUnknown*)collection, NULL, 0);
3827 IHTMLElementCollection_Release(collection);
3830 hres = IHTMLDocument2_get_forms(doc, NULL);
3831 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
3833 hres = IHTMLDocument2_get_forms(doc, &collection);
3834 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
3835 if(hres == S_OK)
3837 test_elem_collection((IUnknown*)collection, NULL, 0);
3838 IHTMLElementCollection_Release(collection);
3841 hres = IHTMLDocument2_get_anchors(doc, NULL);
3842 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
3844 hres = IHTMLDocument2_get_anchors(doc, &collection);
3845 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
3846 if(hres == S_OK)
3848 test_elem_collection((IUnknown*)collection, NULL, 0);
3849 IHTMLElementCollection_Release(collection);
3852 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3853 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
3854 test_default_body(body);
3855 test_body_funs(body);
3856 IHTMLBodyElement_Release(body);
3858 hres = IHTMLElement_get_style(elem, &style);
3859 ok(hres == S_OK, "get_style failed: %08x\n", hres);
3861 test_default_style(style);
3862 test_window(doc);
3863 test_compatmode(doc);
3864 test_location(doc);
3865 test_navigator(doc);
3867 elem2 = get_elem2_iface((IUnknown*)elem);
3868 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
3869 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
3870 if(SUCCEEDED(hres)) {
3871 test_current_style(cstyle);
3872 IHTMLCurrentStyle_Release(cstyle);
3874 IHTMLElement2_Release(elem2);
3876 IHTMLElement_Release(elem);
3878 test_set_csstext(style);
3879 IHTMLStyle_Release(style);
3881 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
3882 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
3884 l = 0xdeadbeef;
3885 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
3886 ok(hres == S_OK, "get_length failed: %08x\n", hres);
3887 ok(l == 0, "length = %d\n", l);
3889 IHTMLStyleSheetsCollection_Release(stylesheetcol);
3891 test_default_selection(doc);
3892 test_doc_title(doc, "");
3895 static void test_tr_elem(IHTMLElement *elem)
3897 IHTMLElementCollection *col;
3898 IHTMLTableRow *row;
3899 HRESULT hres;
3901 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
3903 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
3904 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
3905 if(FAILED(hres))
3906 return;
3908 col = NULL;
3909 hres = IHTMLTableRow_get_cells(row, &col);
3910 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
3911 ok(col != NULL, "get_cells returned NULL\n");
3913 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
3914 IHTMLElementCollection_Release(col);
3916 IHTMLTable_Release(row);
3919 static void test_table_elem(IHTMLElement *elem)
3921 IHTMLElementCollection *col;
3922 IHTMLTable *table;
3923 HRESULT hres;
3925 static const elem_type_t row_types[] = {ET_TR,ET_TR};
3927 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
3928 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
3929 if(FAILED(hres))
3930 return;
3932 col = NULL;
3933 hres = IHTMLTable_get_rows(table, &col);
3934 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
3935 ok(col != NULL, "get_ros returned NULL\n");
3937 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
3938 IHTMLElementCollection_Release(col);
3940 IHTMLTable_Release(table);
3943 static void doc_write(IHTMLDocument2 *doc, const char *text)
3945 SAFEARRAYBOUND dim;
3946 SAFEARRAY *sa;
3947 VARIANT *var;
3948 BSTR str;
3949 HRESULT hres;
3951 dim.lLbound = 0;
3952 dim.cElements = 1;
3953 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
3954 SafeArrayAccessData(sa, (void**)&var);
3955 V_VT(var) = VT_BSTR;
3956 V_BSTR(var) = str = a2bstr(text);
3957 SafeArrayUnaccessData(sa);
3959 hres = IHTMLDocument2_write(doc, sa);
3960 ok(hres == S_OK, "write failed: %08x\n", hres);
3962 SysFreeString(str);
3963 SafeArrayDestroy(sa);
3966 static void test_iframe_elem(IHTMLElement *elem)
3968 IHTMLElementCollection *col;
3969 IHTMLDocument2 *content_doc;
3970 IHTMLWindow2 *content_window;
3971 IHTMLFrameBase2 *base2;
3972 IDispatch *disp;
3973 VARIANT errv;
3974 BSTR str;
3975 HRESULT hres;
3977 static const elem_type_t all_types[] = {
3978 ET_HTML,
3979 ET_HEAD,
3980 ET_TITLE,
3981 ET_BODY,
3982 ET_BR
3985 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
3986 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
3987 if (!base2) return;
3989 content_window = NULL;
3990 hres = IHTMLFrameBase2_get_contentWindow(base2, &content_window);
3991 IHTMLFrameBase2_Release(base2);
3992 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
3993 ok(content_window != NULL, "contentWindow = NULL\n");
3995 content_doc = NULL;
3996 hres = IHTMLWindow2_get_document(content_window, &content_doc);
3997 IHTMLWindow2_Release(content_window);
3998 ok(hres == S_OK, "get_document failed: %08x\n", hres);
3999 ok(content_doc != NULL, "content_doc = NULL\n");
4001 str = a2bstr("text/html");
4002 V_VT(&errv) = VT_ERROR;
4003 disp = NULL;
4004 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4005 SysFreeString(str);
4006 ok(hres == S_OK, "open failed: %08x\n", hres);
4007 ok(disp != NULL, "disp == NULL\n");
4008 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4009 IDispatch_Release(disp);
4011 doc_write(content_doc, "<html><head><title>test</title></head><body><br /></body></html>");
4013 hres = IHTMLDocument2_get_all(content_doc, &col);
4014 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4015 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4016 IHTMLElementCollection_Release(col);
4018 hres = IHTMLDocument2_close(content_doc);
4019 ok(hres == S_OK, "close failed: %08x\n", hres);
4021 IHTMLDocument2_Release(content_doc);
4024 static void test_stylesheet(IDispatch *disp)
4026 IHTMLStyleSheetRulesCollection *col = NULL;
4027 IHTMLStyleSheet *stylesheet;
4028 HRESULT hres;
4030 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4031 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4033 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4034 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4035 ok(col != NULL, "col == NULL\n");
4037 IHTMLStyleSheetRulesCollection_Release(col);
4038 IHTMLStyleSheet_Release(stylesheet);
4041 static void test_stylesheets(IHTMLDocument2 *doc)
4043 IHTMLStyleSheetsCollection *col = NULL;
4044 VARIANT idx, res;
4045 LONG len = 0;
4046 HRESULT hres;
4048 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4049 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4050 ok(col != NULL, "col == NULL\n");
4052 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4053 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4054 ok(len == 1, "len=%d\n", len);
4056 VariantInit(&res);
4057 V_VT(&idx) = VT_I4;
4058 V_I4(&idx) = 0;
4060 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4061 ok(hres == S_OK, "item failed: %08x\n", hres);
4062 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4063 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4064 test_stylesheet(V_DISPATCH(&res));
4065 VariantClear(&res);
4067 V_VT(&res) = VT_I4;
4068 V_VT(&idx) = VT_I4;
4069 V_I4(&idx) = 1;
4071 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4072 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4073 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4074 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4075 VariantClear(&res);
4077 IHTMLStyleSheetsCollection_Release(col);
4080 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4082 IDispatchEx *dispex;
4083 IHTMLDOMNode *node;
4084 DISPPARAMS dp = {NULL, NULL, 0, 0};
4085 VARIANT var;
4086 EXCEPINFO ei;
4087 LONG type;
4088 DISPID id;
4089 BSTR bstr;
4090 HRESULT hres;
4092 static const WCHAR w0[] = {'0',0};
4093 static const WCHAR w100[] = {'1','0','0',0};
4095 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4096 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4098 bstr = SysAllocString(w0);
4099 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4100 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4101 SysFreeString(bstr);
4103 VariantInit(&var);
4104 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4105 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4106 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4107 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4108 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4109 type = get_node_type((IUnknown*)node);
4110 ok(type == 3, "type=%d\n", type);
4111 IHTMLDOMNode_Release(node);
4112 VariantClear(&var);
4114 bstr = SysAllocString(w100);
4115 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4116 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4117 SysFreeString(bstr);
4119 IDispatchEx_Release(dispex);
4124 static void test_elems(IHTMLDocument2 *doc)
4126 IHTMLElementCollection *col;
4127 IHTMLDOMChildrenCollection *child_col;
4128 IHTMLElement *elem, *elem2, *elem3;
4129 IHTMLDOMNode *node, *node2;
4130 IDispatch *disp;
4131 LONG type;
4132 HRESULT hres;
4133 IHTMLElementCollection *collection;
4134 IHTMLDocument3 *doc3;
4135 BSTR str;
4137 static const elem_type_t all_types[] = {
4138 ET_HTML,
4139 ET_HEAD,
4140 ET_TITLE,
4141 ET_STYLE,
4142 ET_BODY,
4143 ET_COMMENT,
4144 ET_A,
4145 ET_INPUT,
4146 ET_SELECT,
4147 ET_OPTION,
4148 ET_OPTION,
4149 ET_TEXTAREA,
4150 ET_TABLE,
4151 ET_TBODY,
4152 ET_TR,
4153 ET_TR,
4154 ET_TD,
4155 ET_TD,
4156 ET_SCRIPT,
4157 ET_TEST,
4158 ET_IMG,
4159 ET_IFRAME
4162 static const elem_type_t item_types[] = {
4163 ET_A,
4164 ET_OPTION,
4165 ET_TEXTAREA
4168 hres = IHTMLDocument2_get_all(doc, &col);
4169 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4170 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4171 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
4172 IHTMLElementCollection_Release(col);
4174 hres = IHTMLDocument2_get_images(doc, &collection);
4175 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4176 if(hres == S_OK)
4178 static const elem_type_t images_types[] = {ET_IMG};
4179 test_elem_collection((IUnknown*)collection, images_types, 1);
4181 IHTMLElementCollection_Release(collection);
4184 hres = IHTMLDocument2_get_links(doc, &collection);
4185 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4186 if(hres == S_OK)
4188 static const elem_type_t images_types[] = {ET_A};
4189 test_elem_collection((IUnknown*)collection, images_types, 1);
4191 IHTMLElementCollection_Release(collection);
4194 hres = IHTMLDocument2_get_anchors(doc, &collection);
4195 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4196 if(hres == S_OK)
4198 static const elem_type_t anchor_types[] = {ET_A};
4199 test_elem_collection((IUnknown*)collection, anchor_types, 1);
4201 IHTMLElementCollection_Release(collection);
4204 elem = get_doc_elem(doc);
4205 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4206 hres = IHTMLElement_get_all(elem, &disp);
4207 IHTMLElement_Release(elem);
4208 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4210 hres = IDispatch_QueryInterface(disp, &IID_IHTMLElementCollection, (void**)&col);
4211 IDispatch_Release(disp);
4212 ok(hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
4213 test_elem_collection((IUnknown*)col, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
4214 IHTMLElementCollection_Release(col);
4216 get_elem_by_id(doc, "xxx", FALSE);
4217 elem = get_doc_elem_by_id(doc, "xxx");
4218 ok(!elem, "elem != NULL\n");
4220 elem = get_doc_elem_by_id(doc, "s");
4221 ok(elem != NULL, "elem == NULL\n");
4222 if(elem) {
4223 test_elem_type((IUnknown*)elem, ET_SELECT);
4224 test_elem_attr(elem, "xxx", NULL);
4225 test_elem_attr(elem, "id", "s");
4226 test_elem_class((IUnknown*)elem, NULL);
4227 test_elem_set_class((IUnknown*)elem, "cl");
4228 test_elem_set_class((IUnknown*)elem, NULL);
4229 test_elem_tabindex((IUnknown*)elem, 0);
4230 test_elem_set_tabindex((IUnknown*)elem, 1);
4232 node = test_node_get_parent((IUnknown*)elem);
4233 ok(node != NULL, "node == NULL\n");
4234 test_node_name((IUnknown*)node, "BODY");
4235 node2 = test_node_get_parent((IUnknown*)node);
4236 IHTMLDOMNode_Release(node);
4237 ok(node2 != NULL, "node == NULL\n");
4238 test_node_name((IUnknown*)node2, "HTML");
4239 node = test_node_get_parent((IUnknown*)node2);
4240 IHTMLDOMNode_Release(node2);
4241 ok(node != NULL, "node == NULL\n");
4242 if (node)
4244 test_node_name((IUnknown*)node, "#document");
4245 type = get_node_type((IUnknown*)node);
4246 ok(type == 9, "type=%d, expected 9\n", type);
4247 node2 = test_node_get_parent((IUnknown*)node);
4248 IHTMLDOMNode_Release(node);
4249 ok(node2 == NULL, "node != NULL\n");
4252 elem2 = test_elem_get_parent((IUnknown*)elem);
4253 ok(elem2 != NULL, "elem2 == NULL\n");
4254 test_node_name((IUnknown*)elem2, "BODY");
4255 elem3 = test_elem_get_parent((IUnknown*)elem2);
4256 IHTMLElement_Release(elem2);
4257 ok(elem3 != NULL, "elem3 == NULL\n");
4258 test_node_name((IUnknown*)elem3, "HTML");
4259 elem2 = test_elem_get_parent((IUnknown*)elem3);
4260 IHTMLElement_Release(elem3);
4261 ok(elem2 == NULL, "elem2 != NULL\n");
4263 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
4264 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
4265 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
4267 test_elem_innertext(elem, "opt1opt2");
4269 IHTMLElement_Release(elem);
4272 elem = get_elem_by_id(doc, "s", TRUE);
4273 if(elem) {
4274 IHTMLSelectElement *select;
4276 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
4277 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
4279 test_select_elem(select);
4281 test_elem_title((IUnknown*)select, NULL);
4282 test_elem_set_title((IUnknown*)select, "Title");
4283 test_elem_title((IUnknown*)select, "Title");
4284 test_elem_offset((IUnknown*)select);
4286 node = get_first_child((IUnknown*)select);
4287 ok(node != NULL, "node == NULL\n");
4288 if(node) {
4289 test_elem_type((IUnknown*)node, ET_OPTION);
4290 IHTMLDOMNode_Release(node);
4293 type = get_node_type((IUnknown*)select);
4294 ok(type == 1, "type=%d\n", type);
4296 IHTMLSelectElement_Release(select);
4298 hres = IHTMLElement_get_document(elem, &disp);
4299 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4300 ok(iface_cmp((IUnknown*)disp, (IUnknown*)doc), "disp != doc\n");
4302 IHTMLElement_Release(elem);
4305 elem = get_elem_by_id(doc, "sc", TRUE);
4306 if(elem) {
4307 IHTMLScriptElement *script;
4308 BSTR type;
4310 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
4311 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
4313 if(hres == S_OK)
4315 VARIANT_BOOL vb;
4317 hres = IHTMLScriptElement_get_type(script, &type);
4318 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4319 ok(!lstrcmpW(type, text_javascriptW), "Unexpected type %s\n", dbgstr_w(type));
4320 SysFreeString(type);
4322 /* test defer */
4323 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
4324 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4326 hres = IHTMLScriptElement_get_defer(script, &vb);
4327 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
4328 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
4330 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
4331 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4334 IHTMLScriptElement_Release(script);
4337 elem = get_elem_by_id(doc, "in", TRUE);
4338 if(elem) {
4339 IHTMLInputElement *input;
4341 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
4342 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
4344 test_elem_id((IUnknown*)elem, "in");
4345 test_elem_put_id((IUnknown*)elem, "newin");
4346 test_input_get_disabled(input, VARIANT_FALSE);
4347 test_input_set_disabled(input, VARIANT_TRUE);
4348 test_input_set_disabled(input, VARIANT_FALSE);
4349 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
4350 test_input_get_disabled(input, VARIANT_TRUE);
4351 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
4352 test_input_get_disabled(input, VARIANT_FALSE);
4353 test_elem_client_size((IUnknown*)elem);
4355 test_node_get_value_str((IUnknown*)elem, NULL);
4356 test_node_put_value_str((IUnknown*)elem, "test");
4357 test_node_get_value_str((IUnknown*)elem, NULL);
4358 test_input_value((IUnknown*)elem, NULL);
4359 test_input_put_value((IUnknown*)elem, "test");
4360 test_input_value((IUnknown*)elem, NULL);
4361 test_elem_class((IUnknown*)elem, "testclass");
4362 test_elem_tabindex((IUnknown*)elem, 2);
4363 test_elem_set_tabindex((IUnknown*)elem, 3);
4364 test_elem_title((IUnknown*)elem, "test title");
4366 test_input_get_defaultchecked(input, VARIANT_FALSE);
4367 test_input_set_defaultchecked(input, VARIANT_TRUE);
4368 test_input_set_defaultchecked(input, VARIANT_FALSE);
4370 test_input_get_checked(input, VARIANT_FALSE);
4371 test_input_set_checked(input, VARIANT_TRUE);
4372 test_input_set_checked(input, VARIANT_FALSE);
4374 IHTMLInputElement_Release(input);
4375 IHTMLElement_Release(elem);
4378 elem = get_elem_by_id(doc, "imgid", TRUE);
4379 if(elem) {
4380 test_img_src((IUnknown*)elem, "");
4381 test_img_set_src((IUnknown*)elem, "about:blank");
4382 test_img_alt((IUnknown*)elem, NULL);
4383 test_img_set_alt((IUnknown*)elem, "alt test");
4384 IHTMLElement_Release(elem);
4387 elem = get_doc_elem_by_id(doc, "tbl");
4388 ok(elem != NULL, "elem == NULL\n");
4389 if(elem) {
4390 test_table_elem(elem);
4391 IHTMLElement_Release(elem);
4394 elem = get_doc_elem_by_id(doc, "row2");
4395 ok(elem != NULL, "elem == NULL\n");
4396 if(elem) {
4397 test_tr_elem(elem);
4398 IHTMLElement_Release(elem);
4401 elem = get_doc_elem_by_id(doc, "ifr");
4402 ok(elem != NULL, "elem == NULL\n");
4403 if(elem) {
4404 test_iframe_elem(elem);
4405 IHTMLElement_Release(elem);
4408 hres = IHTMLDocument2_get_body(doc, &elem);
4409 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4411 node = get_first_child((IUnknown*)elem);
4412 ok(node != NULL, "node == NULL\n");
4413 if(node) {
4414 test_ifaces((IUnknown*)node, text_iids);
4415 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode);
4417 node2 = get_first_child((IUnknown*)node);
4418 ok(!node2, "node2 != NULL\n");
4420 type = get_node_type((IUnknown*)node);
4421 ok(type == 3, "type=%d\n", type);
4423 test_node_get_value_str((IUnknown*)node, "text test");
4424 test_node_put_value_str((IUnknown*)elem, "test text");
4425 test_node_get_value_str((IUnknown*)node, "text test");
4427 IHTMLDOMNode_Release(node);
4430 child_col = get_child_nodes((IUnknown*)elem);
4431 ok(child_col != NULL, "child_coll == NULL\n");
4432 if(child_col) {
4433 LONG length = 0;
4435 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection);
4437 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
4438 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4439 ok(length, "length=0\n");
4441 node = get_child_item(child_col, 0);
4442 ok(node != NULL, "node == NULL\n");
4443 if(node) {
4444 type = get_node_type((IUnknown*)node);
4445 ok(type == 3, "type=%d\n", type);
4446 IHTMLDOMNode_Release(node);
4449 node = get_child_item(child_col, 1);
4450 ok(node != NULL, "node == NULL\n");
4451 if(node) {
4452 type = get_node_type((IUnknown*)node);
4453 ok(type == 8, "type=%d\n", type);
4455 test_elem_id((IUnknown*)node, NULL);
4456 IHTMLDOMNode_Release(node);
4459 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
4460 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
4462 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
4463 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
4465 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
4466 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4468 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
4469 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4471 test_child_col_disp(child_col);
4473 IHTMLDOMChildrenCollection_Release(child_col);
4476 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
4477 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
4478 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
4480 IHTMLElement_Release(elem);
4482 test_stylesheets(doc);
4483 test_create_option_elem(doc);
4485 elem = get_doc_elem_by_id(doc, "tbl");
4486 ok(elem != NULL, "elem = NULL\n");
4487 test_elem_set_innertext(elem, "inner text");
4488 IHTMLElement_Release(elem);
4490 test_doc_title(doc, "test");
4491 test_doc_set_title(doc, "test title");
4492 test_doc_title(doc, "test title");
4494 disp = NULL;
4495 hres = IHTMLDocument2_get_Script(doc, &disp);
4496 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4497 if(hres == S_OK)
4499 IDispatchEx *dispex;
4500 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
4501 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
4502 if(hres == S_OK)
4504 DISPID pid = -1;
4505 BSTR str = a2bstr("Testing");
4506 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
4507 todo_wine ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4508 todo_wine ok(pid != -1, "pid == -1\n");
4509 SysFreeString(str);
4510 IDispatchEx_Release(dispex);
4513 IDispatch_Release(disp);
4515 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4516 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
4518 str = a2bstr("img");
4519 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
4520 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", dbgstr_w(str), hres);
4521 SysFreeString(str);
4522 if(hres == S_OK)
4524 static const elem_type_t img_types[] = { ET_IMG };
4526 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
4527 IHTMLElementCollection_Release(col);
4530 elem = get_doc_elem_by_id(doc, "y");
4531 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
4532 test_elem_innerhtml((IUnknown*)elem, "inner html");
4533 test_elem_set_innerhtml((IUnknown*)elem, "");
4534 test_elem_innerhtml((IUnknown*)elem, NULL);
4535 IHTMLElement_Release(elem);
4537 IHTMLDocument3_Release(doc3);
4540 static void test_create_elems(IHTMLDocument2 *doc)
4542 IHTMLElement *elem, *body, *elem2;
4543 IHTMLDOMNode *node, *node2, *node3, *comment;
4544 IHTMLDocument5 *doc5;
4545 IDispatch *disp;
4546 VARIANT var;
4547 LONG type;
4548 HRESULT hres;
4549 BSTR str;
4551 static const elem_type_t types1[] = { ET_TESTG };
4553 elem = test_create_elem(doc, "TEST");
4554 test_elem_tag((IUnknown*)elem, "TEST");
4555 type = get_node_type((IUnknown*)elem);
4556 ok(type == 1, "type=%d\n", type);
4557 test_ifaces((IUnknown*)elem, elem_iids);
4558 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement);
4560 hres = IHTMLDocument2_get_body(doc, &body);
4561 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4562 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
4564 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
4565 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
4566 elem2 = get_elem_iface((IUnknown*)node);
4567 IHTMLElement_Release(elem2);
4569 hres = IHTMLElement_get_all(body, &disp);
4570 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4571 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
4572 IDispatch_Release(disp);
4574 test_node_remove_child((IUnknown*)body, node);
4576 hres = IHTMLElement_get_all(body, &disp);
4577 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4578 test_elem_collection((IUnknown*)disp, NULL, 0);
4579 IDispatch_Release(disp);
4580 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
4582 IHTMLElement_Release(elem);
4583 IHTMLDOMNode_Release(node);
4585 node = test_create_text(doc, "test");
4586 test_ifaces((IUnknown*)node, text_iids);
4587 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode);
4589 V_VT(&var) = VT_NULL;
4590 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
4591 IHTMLDOMNode_Release(node);
4593 node = test_create_text(doc, "insert ");
4595 V_VT(&var) = VT_DISPATCH;
4596 V_DISPATCH(&var) = (IDispatch*)node2;
4597 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
4598 IHTMLDOMNode_Release(node);
4599 IHTMLDOMNode_Release(node2);
4600 IHTMLDOMNode_Release(node3);
4602 test_elem_innertext(body, "insert test");
4603 test_elem_innerhtml((IUnknown*)body, "insert test");
4605 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
4606 if(hres == S_OK)
4608 str = a2bstr("testing");
4609 hres = IHTMLDocument5_createComment(doc5, str, &comment);
4610 SysFreeString(str);
4611 ok(hres == S_OK, "createComment failed: %08x\n", hres);
4612 if(hres == S_OK)
4614 type = get_node_type((IUnknown*)comment);
4615 ok(type == 8, "type=%d, expected 8\n", type);
4617 test_node_get_value_str((IUnknown*)comment, "testing");
4619 IHTMLDOMNode_Release(comment);
4622 IHTMLDocument5_Release(doc5);
4625 IHTMLElement_Release(body);
4628 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
4630 IOleCommandTarget *cmdtrg;
4631 HRESULT hres;
4633 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
4634 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
4636 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
4637 ok(hres == S_OK, "Exec failed: %08x\n", hres);
4639 IOleCommandTarget_Release(cmdtrg);
4642 static void test_indent(IHTMLDocument2 *doc)
4644 IHTMLElementCollection *col;
4645 IHTMLTxtRange *range;
4646 HRESULT hres;
4648 static const elem_type_t all_types[] = {
4649 ET_HTML,
4650 ET_HEAD,
4651 ET_TITLE,
4652 ET_BODY,
4653 ET_BR,
4654 ET_A,
4657 static const elem_type_t indent_types[] = {
4658 ET_HTML,
4659 ET_HEAD,
4660 ET_TITLE,
4661 ET_BODY,
4662 ET_BLOCKQUOTE,
4663 ET_P,
4664 ET_BR,
4665 ET_A,
4668 hres = IHTMLDocument2_get_all(doc, &col);
4669 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4670 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4671 IHTMLElementCollection_Release(col);
4673 range = test_create_body_range(doc);
4674 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
4675 IHTMLTxtRange_Release(range);
4677 hres = IHTMLDocument2_get_all(doc, &col);
4678 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4679 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
4680 IHTMLElementCollection_Release(col);
4683 static void test_cond_comment(IHTMLDocument2 *doc)
4685 IHTMLElementCollection *col;
4686 HRESULT hres;
4688 static const elem_type_t all_types[] = {
4689 ET_HTML,
4690 ET_HEAD,
4691 ET_TITLE,
4692 ET_BODY,
4693 ET_BR
4696 hres = IHTMLDocument2_get_all(doc, &col);
4697 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4698 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4699 IHTMLElementCollection_Release(col);
4702 static IHTMLDocument2 *notif_doc;
4703 static BOOL doc_complete;
4705 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
4706 REFIID riid, void**ppv)
4708 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
4709 *ppv = iface;
4710 return S_OK;
4713 ok(0, "unexpected call\n");
4714 return E_NOINTERFACE;
4717 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
4719 return 2;
4722 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
4724 return 1;
4727 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
4729 if(dispID == DISPID_READYSTATE){
4730 BSTR state;
4731 HRESULT hres;
4733 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
4735 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
4736 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
4738 if(!lstrcmpW(state, completeW))
4739 doc_complete = TRUE;
4741 SysFreeString(state);
4744 return S_OK;
4747 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
4749 ok(0, "unexpected call\n");
4750 return E_NOTIMPL;
4753 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
4754 PropertyNotifySink_QueryInterface,
4755 PropertyNotifySink_AddRef,
4756 PropertyNotifySink_Release,
4757 PropertyNotifySink_OnChanged,
4758 PropertyNotifySink_OnRequestEdit
4761 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
4763 static IHTMLDocument2 *create_doc_with_string(const char *str)
4765 IPersistStreamInit *init;
4766 IStream *stream;
4767 IHTMLDocument2 *doc;
4768 HGLOBAL mem;
4769 SIZE_T len;
4771 notif_doc = doc = create_document();
4772 if(!doc)
4773 return NULL;
4775 doc_complete = FALSE;
4776 len = strlen(str);
4777 mem = GlobalAlloc(0, len);
4778 memcpy(mem, str, len);
4779 CreateStreamOnHGlobal(mem, TRUE, &stream);
4781 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
4783 IPersistStreamInit_Load(init, stream);
4784 IPersistStreamInit_Release(init);
4785 IStream_Release(stream);
4787 return doc;
4790 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
4792 IConnectionPointContainer *container;
4793 IConnectionPoint *cp;
4794 DWORD cookie;
4795 HRESULT hres;
4797 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
4798 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
4800 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
4801 IConnectionPointContainer_Release(container);
4802 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
4804 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
4805 IConnectionPoint_Release(cp);
4806 ok(hres == S_OK, "Advise failed: %08x\n", hres);
4809 typedef void (*domtest_t)(IHTMLDocument2*);
4811 static void run_domtest(const char *str, domtest_t test)
4813 IHTMLDocument2 *doc;
4814 IHTMLElement *body = NULL;
4815 ULONG ref;
4816 MSG msg;
4817 HRESULT hres;
4819 doc = create_doc_with_string(str);
4820 if(!doc)
4821 return;
4823 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
4825 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
4826 TranslateMessage(&msg);
4827 DispatchMessage(&msg);
4830 hres = IHTMLDocument2_get_body(doc, &body);
4831 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4833 if(body) {
4834 IHTMLElement_Release(body);
4835 test(doc);
4836 }else {
4837 skip("Could not get document body. Assuming no Gecko installed.\n");
4840 ref = IHTMLDocument2_Release(doc);
4841 ok(!ref ||
4842 ref == 1, /* Vista */
4843 "ref = %d\n", ref);
4846 static void gecko_installer_workaround(BOOL disable)
4848 HKEY hkey;
4849 DWORD res;
4851 static BOOL has_url = FALSE;
4852 static char url[2048];
4854 if(!disable && !has_url)
4855 return;
4857 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
4858 if(res != ERROR_SUCCESS)
4859 return;
4861 if(disable) {
4862 DWORD type, size = sizeof(url);
4864 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
4865 if(res == ERROR_SUCCESS && type == REG_SZ)
4866 has_url = TRUE;
4868 RegDeleteValue(hkey, "GeckoUrl");
4869 }else {
4870 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
4873 RegCloseKey(hkey);
4876 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
4877 /* Note: this code is duplicated in dlls/mshtml/tests/dom.c, dlls/mshtml/tests/script.c and dlls/urlmon/tests/misc.c */
4878 static BOOL is_ie_hardened(void)
4880 HKEY zone_map;
4881 DWORD ie_harden, type, size;
4883 ie_harden = 0;
4884 if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
4885 0, KEY_QUERY_VALUE, &zone_map) == ERROR_SUCCESS) {
4886 size = sizeof(DWORD);
4887 if (RegQueryValueEx(zone_map, "IEHarden", NULL, &type, (LPBYTE) &ie_harden, &size) != ERROR_SUCCESS ||
4888 type != REG_DWORD) {
4889 ie_harden = 0;
4891 RegCloseKey(zone_map);
4894 return ie_harden != 0;
4897 START_TEST(dom)
4899 gecko_installer_workaround(TRUE);
4900 CoInitialize(NULL);
4902 run_domtest(doc_str1, test_doc_elem);
4903 run_domtest(range_test_str, test_txtrange);
4904 run_domtest(range_test2_str, test_txtrange2);
4905 if (winetest_interactive || ! is_ie_hardened()) {
4906 run_domtest(elem_test_str, test_elems);
4907 }else {
4908 skip("IE running in Enhanced Security Configuration\n");
4910 run_domtest(doc_blank, test_create_elems);
4911 run_domtest(doc_blank, test_defaults);
4912 run_domtest(indent_test_str, test_indent);
4913 run_domtest(cond_comment_str, test_cond_comment);
4915 CoUninitialize();
4916 gecko_installer_workaround(FALSE);