push cc8bc80451cc24f4d7cf75168b569f0ebfe19547
[wine/hacks.git] / dlls / mshtml / tests / dom.c
blob92b379b7523f51c4e1d574e7c79b196e81aada55
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 WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
62 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
63 static WCHAR wordW[] = {'w','o','r','d',0};
65 typedef enum {
66 ET_NONE,
67 ET_HTML,
68 ET_HEAD,
69 ET_TITLE,
70 ET_BODY,
71 ET_A,
72 ET_INPUT,
73 ET_SELECT,
74 ET_TEXTAREA,
75 ET_OPTION,
76 ET_STYLE,
77 ET_BLOCKQUOTE,
78 ET_P,
79 ET_BR,
80 ET_TABLE,
81 ET_TBODY,
82 ET_SCRIPT,
83 ET_TEST,
84 ET_TESTG,
85 ET_COMMENT,
86 ET_IMG,
87 ET_TR,
88 ET_TD,
89 ET_IFRAME
90 } elem_type_t;
92 static const IID * const none_iids[] = {
93 &IID_IUnknown,
94 NULL
97 static const IID * const elem_iids[] = {
98 &IID_IHTMLDOMNode,
99 &IID_IHTMLDOMNode2,
100 &IID_IHTMLElement,
101 &IID_IHTMLElement2,
102 &IID_IHTMLElement3,
103 &IID_IDispatchEx,
104 &IID_IConnectionPointContainer,
105 NULL
108 static const IID * const body_iids[] = {
109 &IID_IHTMLDOMNode,
110 &IID_IHTMLDOMNode2,
111 &IID_IHTMLElement,
112 &IID_IHTMLElement2,
113 &IID_IHTMLElement3,
114 &IID_IHTMLTextContainer,
115 &IID_IHTMLBodyElement,
116 &IID_IDispatchEx,
117 &IID_IConnectionPointContainer,
118 NULL
121 static const IID * const anchor_iids[] = {
122 &IID_IHTMLDOMNode,
123 &IID_IHTMLDOMNode2,
124 &IID_IHTMLElement,
125 &IID_IHTMLElement2,
126 &IID_IHTMLElement3,
127 &IID_IHTMLAnchorElement,
128 &IID_IDispatchEx,
129 &IID_IConnectionPointContainer,
130 NULL
133 static const IID * const input_iids[] = {
134 &IID_IHTMLDOMNode,
135 &IID_IHTMLDOMNode2,
136 &IID_IHTMLElement,
137 &IID_IHTMLElement2,
138 &IID_IHTMLElement3,
139 &IID_IHTMLInputElement,
140 &IID_IHTMLInputTextElement,
141 &IID_IDispatchEx,
142 &IID_IConnectionPointContainer,
143 NULL
146 static const IID * const select_iids[] = {
147 &IID_IHTMLDOMNode,
148 &IID_IHTMLDOMNode2,
149 &IID_IHTMLElement,
150 &IID_IHTMLElement2,
151 &IID_IHTMLElement3,
152 &IID_IHTMLSelectElement,
153 &IID_IDispatchEx,
154 &IID_IConnectionPointContainer,
155 NULL
158 static const IID * const textarea_iids[] = {
159 &IID_IHTMLDOMNode,
160 &IID_IHTMLDOMNode2,
161 &IID_IHTMLElement,
162 &IID_IHTMLElement2,
163 &IID_IHTMLElement3,
164 &IID_IHTMLTextAreaElement,
165 &IID_IDispatchEx,
166 &IID_IConnectionPointContainer,
167 NULL
170 static const IID * const option_iids[] = {
171 &IID_IHTMLDOMNode,
172 &IID_IHTMLDOMNode2,
173 &IID_IHTMLElement,
174 &IID_IHTMLElement2,
175 &IID_IHTMLElement3,
176 &IID_IHTMLOptionElement,
177 &IID_IDispatchEx,
178 &IID_IConnectionPointContainer,
179 NULL
182 static const IID * const table_iids[] = {
183 &IID_IHTMLDOMNode,
184 &IID_IHTMLDOMNode2,
185 &IID_IHTMLElement,
186 &IID_IHTMLElement2,
187 &IID_IHTMLElement3,
188 &IID_IHTMLTable,
189 &IID_IDispatchEx,
190 &IID_IConnectionPointContainer,
191 NULL
194 static const IID * const script_iids[] = {
195 &IID_IHTMLDOMNode,
196 &IID_IHTMLDOMNode2,
197 &IID_IHTMLElement,
198 &IID_IHTMLElement2,
199 &IID_IHTMLElement3,
200 &IID_IHTMLScriptElement,
201 &IID_IDispatchEx,
202 &IID_IConnectionPointContainer,
203 NULL
206 static const IID * const text_iids[] = {
207 &IID_IHTMLDOMNode,
208 &IID_IHTMLDOMNode2,
209 &IID_IHTMLDOMTextNode,
210 NULL
213 static const IID * const location_iids[] = {
214 &IID_IDispatch,
215 &IID_IHTMLLocation,
216 NULL
219 static const IID * const window_iids[] = {
220 &IID_IDispatch,
221 &IID_IHTMLWindow2,
222 &IID_IHTMLWindow3,
223 &IID_IDispatchEx,
224 NULL
227 static const IID * const comment_iids[] = {
228 &IID_IHTMLDOMNode,
229 &IID_IHTMLDOMNode2,
230 &IID_IHTMLElement,
231 &IID_IHTMLElement2,
232 &IID_IHTMLElement3,
233 &IID_IHTMLCommentElement,
234 &IID_IDispatchEx,
235 &IID_IConnectionPointContainer,
236 NULL
239 static const IID * const img_iids[] = {
240 &IID_IHTMLDOMNode,
241 &IID_IHTMLDOMNode2,
242 &IID_IHTMLElement,
243 &IID_IHTMLElement2,
244 &IID_IHTMLElement3,
245 &IID_IDispatchEx,
246 &IID_IHTMLImgElement,
247 &IID_IConnectionPointContainer,
248 NULL
251 static const IID * const tr_iids[] = {
252 &IID_IHTMLDOMNode,
253 &IID_IHTMLDOMNode2,
254 &IID_IHTMLElement,
255 &IID_IHTMLElement2,
256 &IID_IHTMLElement3,
257 &IID_IDispatchEx,
258 &IID_IHTMLTableRow,
259 &IID_IConnectionPointContainer,
260 NULL
263 static const IID * const td_iids[] = {
264 &IID_IHTMLDOMNode,
265 &IID_IHTMLDOMNode2,
266 &IID_IHTMLElement,
267 &IID_IHTMLElement2,
268 &IID_IHTMLElement3,
269 &IID_IDispatchEx,
270 &IID_IConnectionPointContainer,
271 NULL
274 static const IID * const iframe_iids[] = {
275 &IID_IHTMLDOMNode,
276 &IID_IHTMLDOMNode2,
277 &IID_IHTMLElement,
278 &IID_IHTMLElement2,
279 &IID_IHTMLElement3,
280 &IID_IHTMLFrameBase2,
281 &IID_IDispatchEx,
282 &IID_IConnectionPointContainer,
283 NULL
286 static const IID * const generic_iids[] = {
287 &IID_IHTMLDOMNode,
288 &IID_IHTMLDOMNode2,
289 &IID_IHTMLElement,
290 &IID_IHTMLElement2,
291 &IID_IHTMLElement3,
292 &IID_IHTMLGenericElement,
293 &IID_IDispatchEx,
294 &IID_IConnectionPointContainer,
295 NULL
298 static const IID * const style_iids[] = {
299 &IID_IUnknown,
300 &IID_IDispatch,
301 &IID_IDispatchEx,
302 &IID_IHTMLStyle,
303 &IID_IHTMLStyle2,
304 &IID_IHTMLStyle3,
305 &IID_IHTMLStyle4,
306 NULL
309 static const IID * const cstyle_iids[] = {
310 &IID_IUnknown,
311 &IID_IDispatch,
312 &IID_IDispatchEx,
313 &IID_IHTMLCurrentStyle,
314 NULL
317 typedef struct {
318 const char *tag;
319 REFIID *iids;
320 const IID *dispiid;
321 } elem_type_info_t;
323 static const elem_type_info_t elem_type_infos[] = {
324 {"", none_iids, NULL},
325 {"HTML", elem_iids, NULL},
326 {"HEAD", elem_iids, NULL},
327 {"TITLE", elem_iids, NULL},
328 {"BODY", body_iids, &DIID_DispHTMLBody},
329 {"A", anchor_iids, NULL},
330 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
331 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
332 {"TEXTAREA", textarea_iids, NULL},
333 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
334 {"STYLE", elem_iids, NULL},
335 {"BLOCKQUOTE",elem_iids, NULL},
336 {"P", elem_iids, NULL},
337 {"BR", elem_iids, NULL},
338 {"TABLE", table_iids, &DIID_DispHTMLTable},
339 {"TBODY", elem_iids, NULL},
340 {"SCRIPT", script_iids, NULL},
341 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
342 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
343 {"!", comment_iids, &DIID_DispHTMLCommentElement},
344 {"IMG", img_iids, &DIID_DispHTMLImg},
345 {"TR", tr_iids, &DIID_DispHTMLTableRow},
346 {"TD", td_iids, NULL},
347 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}
350 static const char *dbgstr_w(LPCWSTR str)
352 static char buf[512];
353 if(!str)
354 return "(null)";
355 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
356 return buf;
359 static const char *dbgstr_guid(REFIID riid)
361 static char buf[50];
363 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
364 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
365 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
366 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
368 return buf;
371 static int strcmp_wa(LPCWSTR strw, const char *stra)
373 CHAR buf[512];
374 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
375 return lstrcmpA(stra, buf);
378 static BSTR a2bstr(const char *str)
380 BSTR ret;
381 int len;
383 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
384 ret = SysAllocStringLen(NULL, len);
385 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
387 return ret;
390 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
392 IUnknown *unk1, *unk2;
394 if(iface1 == iface2)
395 return TRUE;
397 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
398 IUnknown_Release(unk1);
399 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk2);
400 IUnknown_Release(unk2);
402 return unk1 == unk2;
405 static IHTMLDocument2 *create_document(void)
407 IHTMLDocument2 *doc;
408 IHTMLDocument5 *doc5;
409 HRESULT hres;
411 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
412 &IID_IHTMLDocument2, (void**)&doc);
413 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
415 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
416 if(FAILED(hres)) {
417 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
418 IHTMLDocument2_Release(doc);
419 return NULL;
422 IHTMLDocument5_Release(doc5);
423 return doc;
426 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
427 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
429 const IID * const *piid;
430 IUnknown *unk;
431 HRESULT hres;
433 for(piid = iids; *piid; piid++) {
434 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
435 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
436 if(SUCCEEDED(hres))
437 IUnknown_Release(unk);
441 #define test_disp(u,id) _test_disp(__LINE__,u,id)
442 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid)
444 IDispatchEx *dispex;
445 ITypeInfo *typeinfo;
446 UINT ticnt;
447 HRESULT hres;
449 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
450 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
451 if(FAILED(hres))
452 return;
454 ticnt = 0xdeadbeef;
455 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
456 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
457 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
459 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
460 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
462 if(SUCCEEDED(hres)) {
463 TYPEATTR *type_attr;
465 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
466 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
467 ok_(__FILE__,line) (IsEqualGUID(&type_attr->guid, diid), "unexpected guid %s\n", dbgstr_guid(&type_attr->guid));
469 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
470 ITypeInfo_Release(typeinfo);
473 IDispatchEx_Release(dispex);
476 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
477 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
479 IHTMLElement *elem;
480 HRESULT hres;
482 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
483 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
484 return elem;
487 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
488 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
490 IHTMLElement2 *elem;
491 HRESULT hres;
493 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
494 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
495 return elem;
498 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
499 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
501 IHTMLElement3 *elem;
502 HRESULT hres;
504 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
505 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
506 return elem;
509 #define get_node_iface(u) _get_node_iface(__LINE__,u)
510 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
512 IHTMLDOMNode *node;
513 HRESULT hres;
515 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
516 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
517 return node;
520 #define get_img_iface(u) _get_img_iface(__LINE__,u)
521 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
523 IHTMLImgElement *img;
524 HRESULT hres;
526 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
527 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
528 return img;
531 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
532 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
534 IHTMLDOMNode *node = _get_node_iface(line, unk);
535 BSTR name;
536 HRESULT hres;
538 hres = IHTMLDOMNode_get_nodeName(node, &name);
539 IHTMLDOMNode_Release(node);
540 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
541 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", dbgstr_w(name), exname);
543 SysFreeString(name);
546 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
547 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
549 IHTMLElement *elem = _get_elem_iface(line, unk);
550 BSTR tag;
551 HRESULT hres;
553 hres = IHTMLElement_get_tagName(elem, &tag);
554 IHTMLElement_Release(elem);
555 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
556 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", dbgstr_w(tag), extag);
558 SysFreeString(tag);
561 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
562 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
564 _test_elem_tag(line, unk, elem_type_infos[type].tag);
565 _test_ifaces(line, unk, elem_type_infos[type].iids);
567 if(elem_type_infos[type].dispiid)
568 _test_disp(line, unk, elem_type_infos[type].dispiid);
571 #define get_node_type(n) _get_node_type(__LINE__,n)
572 static LONG _get_node_type(unsigned line, IUnknown *unk)
574 IHTMLDOMNode *node = _get_node_iface(line, unk);
575 LONG type = -1;
576 HRESULT hres;
578 hres = IHTMLDOMNode_get_nodeType(node, &type);
579 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
581 IHTMLDOMNode_Release(node);
583 return type;
586 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
587 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
589 IHTMLDOMNode *node = _get_node_iface(line, unk);
590 IHTMLDOMChildrenCollection *col = NULL;
591 IDispatch *disp;
592 HRESULT hres;
594 hres = IHTMLDOMNode_get_childNodes(node, &disp);
595 IHTMLDOMNode_Release(node);
596 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
597 if(FAILED(hres))
598 return NULL;
600 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
601 IDispatch_Release(disp);
602 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
604 return col;
607 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
608 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
610 IHTMLDOMNode *node = NULL;
611 IDispatch *disp;
612 HRESULT hres;
614 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
615 ok(hres == S_OK, "item failed: %08x\n", hres);
617 node = _get_node_iface(line, (IUnknown*)disp);
618 IDispatch_Release(disp);
620 return node;
623 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
624 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
626 VARIANT value;
627 BSTR tmp;
628 HRESULT hres;
630 VariantInit(&value);
632 tmp = a2bstr(name);
633 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
634 SysFreeString(tmp);
635 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
637 if(exval) {
638 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
639 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", dbgstr_w(V_BSTR(&value)));
640 }else {
641 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
644 VariantClear(&value);
647 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
648 static void _test_elem_offset(unsigned line, IUnknown *unk)
650 IHTMLElement *elem = _get_elem_iface(line, unk);
651 LONG l;
652 HRESULT hres;
654 hres = IHTMLElement_get_offsetTop(elem, &l);
655 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
657 hres = IHTMLElement_get_offsetHeight(elem, &l);
658 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
660 hres = IHTMLElement_get_offsetWidth(elem, &l);
661 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
663 IHTMLElement_Release(elem);
666 static void test_doc_elem(IHTMLDocument2 *doc)
668 IHTMLElement *elem;
669 IHTMLDocument3 *doc3;
670 HRESULT hres;
672 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
673 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
675 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
676 IHTMLDocument3_Release(doc3);
677 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
679 test_node_name((IUnknown*)elem, "HTML");
680 test_elem_tag((IUnknown*)elem, "HTML");
682 IHTMLElement_Release(elem);
685 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
686 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
688 IHTMLElement *elem;
689 IHTMLDocument3 *doc3;
690 HRESULT hres;
692 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
693 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
694 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
695 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
696 IHTMLDocument3_Release(doc3);
698 return elem;
701 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
702 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
704 BSTR bstr;
705 HRESULT hres;
707 hres = IHTMLOptionElement_get_text(option, &bstr);
708 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
709 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", dbgstr_w(bstr));
710 SysFreeString(bstr);
713 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
714 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
716 BSTR bstr;
717 HRESULT hres;
719 bstr = a2bstr(text);
720 hres = IHTMLOptionElement_put_text(option, bstr);
721 SysFreeString(bstr);
722 ok(hres == S_OK, "put_text failed: %08x\n", hres);
724 _test_option_text(line, option, text);
727 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
728 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
730 BSTR bstr;
731 HRESULT hres;
733 hres = IHTMLOptionElement_get_value(option, &bstr);
734 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
735 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", dbgstr_w(bstr));
736 SysFreeString(bstr);
739 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
740 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
742 BSTR bstr;
743 HRESULT hres;
745 bstr = a2bstr(value);
746 hres = IHTMLOptionElement_put_value(option, bstr);
747 SysFreeString(bstr);
748 ok(hres == S_OK, "put_value failed: %08x\n", hres);
750 _test_option_value(line, option, value);
753 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
754 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
755 const char *txt, const char *val)
757 IHTMLOptionElementFactory *factory;
758 IHTMLOptionElement *option;
759 IHTMLWindow2 *window;
760 VARIANT text, value, empty;
761 HRESULT hres;
763 hres = IHTMLDocument2_get_parentWindow(doc, &window);
764 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
766 hres = IHTMLWindow2_get_Option(window, &factory);
767 IHTMLWindow2_Release(window);
768 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
770 V_VT(&text) = VT_BSTR;
771 V_BSTR(&text) = a2bstr(txt);
772 V_VT(&value) = VT_BSTR;
773 V_BSTR(&value) = a2bstr(val);
774 V_VT(&empty) = VT_EMPTY;
776 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
777 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
779 IHTMLOptionElementFactory_Release(factory);
780 VariantClear(&text);
781 VariantClear(&value);
783 _test_option_text(line, option, txt);
784 _test_option_value(line, option, val);
786 return option;
789 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
790 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
792 LONG len = 0xdeadbeef;
793 HRESULT hres;
795 hres = IHTMLSelectElement_get_length(select, &len);
796 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
797 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
800 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
801 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
803 LONG idx = 0xdeadbeef;
804 HRESULT hres;
806 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
807 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
808 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
811 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
812 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
814 HRESULT hres;
816 hres = IHTMLSelectElement_put_selectedIndex(select, index);
817 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
818 _test_select_selidx(line, select, index);
821 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
822 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
824 BSTR val;
825 HRESULT hres;
827 hres = IHTMLSelectElement_get_value(select, &val);
828 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
829 if(exval)
830 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", dbgstr_w(val));
831 else
832 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", dbgstr_w(val));
835 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
836 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
838 BSTR bstr;
839 HRESULT hres;
841 bstr = a2bstr(val);
842 hres = IHTMLSelectElement_put_value(select, bstr);
843 SysFreeString(bstr);
844 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
847 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
848 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
850 BSTR type;
851 HRESULT hres;
853 hres = IHTMLSelectElement_get_type(select, &type);
854 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
855 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", dbgstr_w(type), extype);
858 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
859 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
861 BSTR text;
862 HRESULT hres;
864 hres = IHTMLTxtRange_get_text(range, &text);
865 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
867 if(extext) {
868 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
869 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=\"%s\", expected \"%s\"\n", dbgstr_w(text), extext);
870 }else {
871 ok_(__FILE__, line) (text == NULL, "text=\"%s\", expected NULL\n", dbgstr_w(text));
874 SysFreeString(text);
878 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
879 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
881 HRESULT hres;
883 hres = IHTMLTxtRange_collapse(range, b);
884 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
885 _test_range_text(line, range, NULL);
888 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
889 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
890 VARIANT_BOOL exb, const char *extext)
892 VARIANT_BOOL b = 0xe0e0;
893 HRESULT hres;
895 hres = IHTMLTxtRange_expand(range, unit, &b);
896 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
897 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
898 _test_range_text(line, range, extext);
901 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
902 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
904 LONG c = 0xdeadbeef;
905 HRESULT hres;
907 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
908 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
909 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
910 _test_range_text(line, range, NULL);
913 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
914 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
915 LPWSTR unit, LONG cnt, LONG excnt)
917 LONG c = 0xdeadbeef;
918 HRESULT hres;
920 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
921 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
922 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
925 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
926 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
928 LONG c = 0xdeadbeef;
929 HRESULT hres;
931 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
932 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
933 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
936 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
937 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
939 HRESULT hres;
940 BSTR bstr = a2bstr(text);
942 hres = IHTMLTxtRange_put_text(range, bstr);
943 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
944 SysFreeString(bstr);
945 _test_range_text(line, range, NULL);
948 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
949 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
951 VARIANT_BOOL b;
952 HRESULT hres;
954 b = 0xe0e0;
955 hres = IHTMLTxtRange_inRange(range1, range2, &b);
956 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
957 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
960 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
961 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
963 VARIANT_BOOL b;
964 HRESULT hres;
966 b = 0xe0e0;
967 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
968 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
969 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
971 b = 0xe0e0;
972 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
973 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
974 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
976 if(exb) {
977 test_range_inrange(range1, range2, VARIANT_TRUE);
978 test_range_inrange(range2, range1, VARIANT_TRUE);
982 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
983 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
985 IHTMLElement *elem;
986 HRESULT hres;
988 hres = IHTMLTxtRange_parentElement(range, &elem);
989 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
991 _test_elem_type(line, (IUnknown*)elem, type);
993 IHTMLElement_Release(elem);
996 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
997 static void _test_elem_collection(unsigned line, IUnknown *unk,
998 const elem_type_t *elem_types, LONG exlen)
1000 IHTMLElementCollection *col;
1001 LONG len;
1002 DWORD i;
1003 VARIANT name, index;
1004 IDispatch *disp;
1005 HRESULT hres;
1007 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1008 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1010 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection);
1012 hres = IHTMLElementCollection_get_length(col, &len);
1013 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1014 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1016 if(len > exlen)
1017 len = exlen;
1019 V_VT(&index) = VT_EMPTY;
1020 V_VT(&name) = VT_I4;
1022 for(i=0; i<len; i++) {
1023 V_I4(&name) = i;
1024 disp = (void*)0xdeadbeef;
1025 hres = IHTMLElementCollection_item(col, name, index, &disp);
1026 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1027 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1028 if(FAILED(hres) || !disp)
1029 continue;
1031 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1032 IDispatch_Release(disp);
1035 V_I4(&name) = len;
1036 disp = (void*)0xdeadbeef;
1037 hres = IHTMLElementCollection_item(col, name, index, &disp);
1038 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1039 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1041 V_I4(&name) = -1;
1042 disp = (void*)0xdeadbeef;
1043 hres = IHTMLElementCollection_item(col, name, index, &disp);
1044 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1045 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1047 IHTMLElementCollection_Release(col);
1050 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1051 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1053 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1054 IHTMLElementCollection *col = NULL;
1055 elem_type_t *types = NULL;
1056 BSTR tmp;
1057 int i;
1058 HRESULT hres;
1060 tmp = a2bstr(elem_type_infos[type].tag);
1061 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1062 SysFreeString(tmp);
1063 IHTMLElement2_Release(elem);
1064 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1065 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1067 if(exlen) {
1068 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1069 for(i=0; i<exlen; i++)
1070 types[i] = type;
1073 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1075 HeapFree(GetProcessHeap(), 0, types);
1078 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1079 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1081 BSTR text = NULL;
1082 HRESULT hres;
1084 hres = IHTMLElement_get_innerText(elem, &text);
1085 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1086 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1087 dbgstr_w(text), extext);
1088 SysFreeString(text);
1091 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1092 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1094 IHTMLDOMChildrenCollection *col;
1095 BSTR str;
1096 HRESULT hres;
1098 str = a2bstr(text);
1099 hres = IHTMLElement_put_innerText(elem, str);
1100 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1101 SysFreeString(str);
1103 _test_elem_innertext(line, elem, text);
1106 col = _get_child_nodes(line, (IUnknown*)elem);
1107 ok(col != NULL, "col == NULL\n");
1108 if(col) {
1109 LONG length = 0, type;
1110 IHTMLDOMNode *node;
1112 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1113 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1114 ok(length == 1, "length = %d\n", length);
1116 node = _get_child_item(line, col, 0);
1117 ok(node != NULL, "node == NULL\n");
1118 if(node) {
1119 type = _get_node_type(line, (IUnknown*)node);
1120 ok(type == 3, "type=%d\n", type);
1121 IHTMLDOMNode_Release(node);
1124 IHTMLDOMChildrenCollection_Release(col);
1129 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1130 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1132 IHTMLElement *elem = _get_elem_iface(line, unk);
1133 BSTR html;
1134 HRESULT hres;
1136 hres = IHTMLElement_get_innerHTML(elem, &html);
1137 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1138 if(inner_html)
1139 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", dbgstr_w(html));
1140 else
1141 ok_(__FILE__,line)(!html, "innerHTML = %s\n", dbgstr_w(html));
1143 IHTMLElement_Release(elem);
1144 SysFreeString(html);
1147 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1148 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1150 IHTMLElement *elem = _get_elem_iface(line, unk);
1151 BSTR html;
1152 HRESULT hres;
1154 html = a2bstr(inner_html);
1155 hres = IHTMLElement_put_innerHTML(elem, html);
1156 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1158 IHTMLElement_Release(elem);
1159 SysFreeString(html);
1162 #define get_first_child(n) _get_first_child(__LINE__,n)
1163 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1165 IHTMLDOMNode *node = _get_node_iface(line, unk);
1166 IHTMLDOMNode *child = NULL;
1167 HRESULT hres;
1169 hres = IHTMLDOMNode_get_firstChild(node, &child);
1170 IHTMLDOMNode_Release(node);
1171 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1173 return child;
1176 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1177 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1179 IHTMLDOMNode *node = _get_node_iface(line, unk);
1180 VARIANT_BOOL b = 0xdead;
1181 HRESULT hres;
1183 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1184 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1185 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1187 IHTMLDOMNode_Release(node);
1190 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1191 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1193 IHTMLDOMNode *node = _get_node_iface(line, unk);
1194 IHTMLDOMNode *parent;
1195 HRESULT hres;
1197 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1198 IHTMLDOMNode_Release(node);
1199 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1201 return parent;
1204 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1205 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1207 IHTMLElement *elem = _get_elem_iface(line, unk);
1208 IHTMLElement *parent;
1209 HRESULT hres;
1211 hres = IHTMLElement_get_parentElement(elem, &parent);
1212 IHTMLElement_Release(elem);
1213 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1215 return parent;
1218 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1219 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1221 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1222 VARIANT_BOOL disabled = 100;
1223 HRESULT hres;
1225 if (!elem3) return;
1226 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1227 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1228 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1229 IHTMLElement3_Release(elem3);
1232 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1233 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1235 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1236 HRESULT hres;
1238 if (!elem3) return;
1239 hres = IHTMLElement3_put_disabled(elem3, b);
1240 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1242 IHTMLElement3_Release(elem3);
1243 _test_elem3_get_disabled(line, unk, b);
1246 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1247 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1249 VARIANT_BOOL disabled = 100;
1250 HRESULT hres;
1252 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1253 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1254 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1256 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1259 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1260 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1262 HRESULT hres;
1264 hres = IHTMLSelectElement_put_disabled(select, b);
1265 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1267 _test_select_get_disabled(line, select, b);
1270 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1271 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1273 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1274 IHTMLTextContainer *txtcont;
1275 LONG l = -1, l2 = -1;
1276 HRESULT hres;
1278 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1279 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1280 IHTMLElement2_Release(elem);
1282 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1283 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1285 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1286 IHTMLTextContainer_Release(txtcont);
1287 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1288 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1290 return l;
1293 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1294 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1296 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1297 IHTMLTextContainer *txtcont;
1298 LONG l = -1, l2 = -1;
1299 HRESULT hres;
1301 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1302 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1303 IHTMLElement2_Release(elem);
1305 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1306 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1308 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1309 IHTMLTextContainer_Release(txtcont);
1310 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1311 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1313 return l;
1316 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1317 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1319 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1320 IHTMLTextContainer *txtcont;
1321 LONG l = -1, l2 = -1;
1322 HRESULT hres;
1324 hres = IHTMLElement2_get_scrollTop(elem, &l);
1325 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1326 IHTMLElement2_Release(elem);
1328 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1329 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1331 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1332 IHTMLTextContainer_Release(txtcont);
1333 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1334 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1336 return l;
1339 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1340 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1342 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1343 IHTMLTextContainer *txtcont;
1344 LONG l = -1, l2 = -1;
1345 HRESULT hres;
1347 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1348 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1350 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1351 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1352 IHTMLElement2_Release(elem);
1354 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1355 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1357 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1358 IHTMLTextContainer_Release(txtcont);
1359 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1360 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1363 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1364 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1366 IHTMLImgElement *img = _get_img_iface(line, unk);
1367 BSTR src;
1368 HRESULT hres;
1370 hres = IHTMLImgElement_get_src(img, &src);
1371 IHTMLImgElement_Release(img);
1372 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1373 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", dbgstr_w(src), exsrc);
1374 SysFreeString(src);
1377 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1378 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1380 IHTMLImgElement *img = _get_img_iface(line, unk);
1381 BSTR tmp;
1382 HRESULT hres;
1384 tmp = a2bstr(src);
1385 hres = IHTMLImgElement_put_src(img, tmp);
1386 IHTMLImgElement_Release(img);
1387 SysFreeString(tmp);
1388 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1390 _test_img_src(line, unk, src);
1393 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1394 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1396 IHTMLImgElement *img = _get_img_iface(line, unk);
1397 BSTR alt;
1398 HRESULT hres;
1400 hres = IHTMLImgElement_get_alt(img, &alt);
1401 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1402 if(exalt)
1403 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", dbgstr_w(alt));
1404 else
1405 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1406 SysFreeString(alt);
1409 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1410 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1412 IHTMLImgElement *img = _get_img_iface(line, unk);
1413 BSTR tmp;
1414 HRESULT hres;
1416 tmp = a2bstr(alt);
1417 hres = IHTMLImgElement_put_alt(img, tmp);
1418 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1419 SysFreeString(tmp);
1421 _test_img_alt(line, unk, alt);
1424 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1425 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1427 VARIANT_BOOL disabled = 100;
1428 HRESULT hres;
1430 hres = IHTMLInputElement_get_disabled(input, &disabled);
1431 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1432 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1434 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1437 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1438 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1440 HRESULT hres;
1442 hres = IHTMLInputElement_put_disabled(input, b);
1443 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1445 _test_input_get_disabled(line, input, b);
1448 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1449 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1451 VARIANT_BOOL checked = 100;
1452 HRESULT hres;
1454 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1455 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1456 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1459 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1460 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1462 HRESULT hres;
1464 hres = IHTMLInputElement_put_defaultChecked(input, b);
1465 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1467 _test_input_get_defaultchecked(line, input, b);
1470 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1471 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1473 VARIANT_BOOL checked = 100;
1474 HRESULT hres;
1476 hres = IHTMLInputElement_get_checked(input, &checked);
1477 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1478 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1481 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1482 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1484 HRESULT hres;
1486 hres = IHTMLInputElement_put_checked(input, b);
1487 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1489 _test_input_get_checked(line, input, b);
1492 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1493 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1495 IHTMLInputElement *input;
1496 BSTR bstr;
1497 HRESULT hres;
1499 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1500 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1501 if(FAILED(hres))
1502 return;
1504 hres = IHTMLInputElement_get_value(input, &bstr);
1505 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1506 if(exval)
1507 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", dbgstr_w(bstr));
1508 else
1509 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1510 SysFreeString(bstr);
1511 IHTMLInputElement_Release(input);
1514 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1515 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1517 IHTMLInputElement *input;
1518 BSTR bstr;
1519 HRESULT hres;
1521 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1522 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1523 if(FAILED(hres))
1524 return;
1526 bstr = a2bstr(val);
1527 hres = IHTMLInputElement_get_value(input, &bstr);
1528 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1529 SysFreeString(bstr);
1530 IHTMLInputElement_Release(input);
1533 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1534 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
1536 IHTMLElement *elem = _get_elem_iface(line, unk);
1537 BSTR class = (void*)0xdeadbeef;
1538 HRESULT hres;
1540 hres = IHTMLElement_get_className(elem, &class);
1541 IHTMLElement_Release(elem);
1542 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
1543 if(exclass)
1544 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", dbgstr_w(class));
1545 else
1546 ok_(__FILE__,line) (!class, "class != NULL\n");
1547 SysFreeString(class);
1550 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1551 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
1553 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1554 short index = -3;
1555 HRESULT hres;
1557 hres = IHTMLElement2_get_tabIndex(elem2, &index);
1558 IHTMLElement2_Release(elem2);
1559 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1560 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
1563 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1564 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
1566 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1567 HRESULT hres;
1569 hres = IHTMLElement2_put_tabIndex(elem2, index);
1570 IHTMLElement2_Release(elem2);
1571 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1573 _test_elem_tabindex(line, unk, index);
1576 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1577 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
1579 IHTMLElement *elem = _get_elem_iface(line, unk);
1580 BSTR tmp;
1581 HRESULT hres;
1583 tmp = class ? a2bstr(class) : NULL;
1584 hres = IHTMLElement_put_className(elem, tmp);
1585 IHTMLElement_Release(elem);
1586 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
1587 SysFreeString(tmp);
1589 _test_elem_class(line, unk, class);
1592 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1593 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
1595 IHTMLElement *elem = _get_elem_iface(line, unk);
1596 BSTR id = (void*)0xdeadbeef;
1597 HRESULT hres;
1599 hres = IHTMLElement_get_id(elem, &id);
1600 IHTMLElement_Release(elem);
1601 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
1603 if(exid)
1604 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", dbgstr_w(id));
1605 else
1606 ok_(__FILE__,line) (!id, "id=%s\n", dbgstr_w(id));
1608 SysFreeString(id);
1611 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1612 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
1614 IHTMLElement *elem = _get_elem_iface(line, unk);
1615 BSTR tmp = a2bstr(new_id);
1616 HRESULT hres;
1618 hres = IHTMLElement_put_id(elem, tmp);
1619 IHTMLElement_Release(elem);
1620 SysFreeString(tmp);
1621 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
1623 _test_elem_id(line, unk, new_id);
1626 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1627 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
1629 IHTMLElement *elem = _get_elem_iface(line, unk);
1630 BSTR title;
1631 HRESULT hres;
1633 hres = IHTMLElement_get_title(elem, &title);
1634 IHTMLElement_Release(elem);
1635 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1636 if(extitle)
1637 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", dbgstr_w(title));
1638 else
1639 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", dbgstr_w(title));
1641 SysFreeString(title);
1644 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1645 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
1647 IHTMLElement *elem = _get_elem_iface(line, unk);
1648 BSTR tmp;
1649 HRESULT hres;
1651 tmp = a2bstr(title);
1652 hres = IHTMLElement_put_title(elem, tmp);
1653 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1655 IHTMLElement_Release(elem);
1656 SysFreeString(tmp);
1659 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1660 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
1662 IHTMLDOMNode *node = _get_node_iface(line, unk);
1663 VARIANT var;
1664 HRESULT hres;
1666 hres = IHTMLDOMNode_get_nodeValue(node, &var);
1667 IHTMLDOMNode_Release(node);
1668 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1670 if(exval) {
1671 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
1672 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", dbgstr_w(V_BSTR(&var)));
1673 }else {
1674 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
1677 VariantClear(&var);
1680 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
1681 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
1683 IHTMLDOMNode *node = _get_node_iface(line, unk);
1684 VARIANT var;
1685 HRESULT hres;
1687 V_VT(&var) = VT_BSTR;
1688 V_BSTR(&var) = a2bstr(val);
1690 hres = IHTMLDOMNode_put_nodeValue(node, var);
1691 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1692 IHTMLDOMNode_Release(node);
1693 VariantClear(&var);
1696 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
1697 static void _test_elem_client_size(unsigned line, IUnknown *unk)
1699 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1700 LONG l;
1701 HRESULT hres;
1703 hres = IHTMLElement2_get_clientWidth(elem, &l);
1704 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
1705 hres = IHTMLElement2_get_clientHeight(elem, &l);
1706 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
1708 IHTMLElement2_Release(elem);
1711 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
1712 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
1714 IHTMLElement *elem = NULL;
1715 BSTR tmp;
1716 HRESULT hres;
1718 tmp = a2bstr(tag);
1719 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
1720 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
1721 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
1723 return elem;
1726 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
1727 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
1729 IHTMLDocument3 *doc3;
1730 IHTMLDOMNode *node = NULL;
1731 BSTR tmp;
1732 HRESULT hres;
1734 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1735 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
1737 tmp = a2bstr(text);
1738 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
1739 IHTMLDocument3_Release(doc3);
1740 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
1741 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
1743 return node;
1746 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
1747 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
1749 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
1750 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
1751 IHTMLDOMNode *new_child = NULL;
1752 HRESULT hres;
1754 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
1755 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
1756 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
1757 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
1759 IHTMLDOMNode_Release(node);
1760 IHTMLDOMNode_Release(child);
1762 return new_child;
1765 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
1766 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
1768 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
1769 IHTMLDOMNode *new_child = NULL;
1770 HRESULT hres;
1772 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
1773 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
1774 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
1775 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
1777 IHTMLDOMNode_Release(node);
1779 return new_child;
1782 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
1783 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
1785 IHTMLDOMNode *node = _get_node_iface(line, unk);
1786 IHTMLDOMNode *new_node = NULL;
1787 HRESULT hres;
1789 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
1790 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
1791 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
1792 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
1794 IHTMLDOMNode_Release(node);
1795 IHTMLDOMNode_Release(new_node);
1798 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
1799 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
1801 BSTR title = NULL;
1802 HRESULT hres;
1804 hres = IHTMLDocument2_get_title(doc, &title);
1805 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1806 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", dbgstr_w(title));
1807 SysFreeString(title);
1810 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
1811 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
1813 BSTR tmp;
1814 HRESULT hres;
1816 tmp = a2bstr(title);
1817 hres = IHTMLDocument2_put_title(doc, tmp);
1818 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1819 SysFreeString(tmp);
1822 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
1823 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
1825 HRESULT hres;
1826 DISPID dispid;
1828 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
1829 LOCALE_USER_DEFAULT, &dispid);
1830 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
1831 if(hres == S_OK)
1833 DISPPARAMS params = {NULL,NULL,0,0};
1834 DISPID dispidNamed = DISPID_PROPERTYPUT;
1835 VARIANT ret;
1836 VARIANT vDefault;
1837 VARIANTARG arg;
1839 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1840 DISPATCH_PROPERTYGET, &params, &vDefault, NULL, NULL);
1841 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
1843 params.cArgs = 1;
1844 params.cNamedArgs = 1;
1845 params.rgdispidNamedArgs = &dispidNamed;
1846 V_VT(&arg) = VT_BSTR;
1847 V_BSTR(&arg) = a2bstr("none");
1848 params.rgvarg = &arg;
1849 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1850 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1851 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
1852 VariantClear(&arg);
1854 V_VT(&arg) = VT_BSTR;
1855 V_BSTR(&arg) = a2bstr("dotted");
1856 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1857 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1858 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
1859 VariantClear(&arg);
1861 V_VT(&arg) = VT_BSTR;
1862 V_BSTR(&arg) = a2bstr("dashed");
1863 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1864 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1865 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
1866 VariantClear(&arg);
1868 V_VT(&arg) = VT_BSTR;
1869 V_BSTR(&arg) = a2bstr("solid");
1870 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1871 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1872 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
1873 VariantClear(&arg);
1875 V_VT(&arg) = VT_BSTR;
1876 V_BSTR(&arg) = a2bstr("double");
1877 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1878 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1879 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
1880 VariantClear(&arg);
1882 V_VT(&arg) = VT_BSTR;
1883 V_BSTR(&arg) = a2bstr("groove");
1884 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1885 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1886 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
1887 VariantClear(&arg);
1889 V_VT(&arg) = VT_BSTR;
1890 V_BSTR(&arg) = a2bstr("ridge");
1891 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1892 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1893 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
1894 VariantClear(&arg);
1896 V_VT(&arg) = VT_BSTR;
1897 V_BSTR(&arg) = a2bstr("inset");
1898 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1899 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1900 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
1901 VariantClear(&arg);
1903 V_VT(&arg) = VT_BSTR;
1904 V_BSTR(&arg) = a2bstr("outset");
1905 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1906 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1907 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
1908 VariantClear(&arg);
1910 V_VT(&arg) = VT_BSTR;
1911 V_BSTR(&arg) = a2bstr("invalid");
1912 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1913 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1914 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
1915 VariantClear(&arg);
1917 params.rgvarg = &vDefault;
1918 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
1919 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
1920 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
1924 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
1925 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
1927 BSTR text = (void*)0xdeadbeef;
1928 HRESULT hres;
1930 hres = IHTMLStyle_get_cssText(style, &text);
1931 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
1932 if(extext)
1933 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", dbgstr_w(text));
1934 else
1935 ok_(__FILE__,line)(!text, "cssText = %s\n", dbgstr_w(text));
1937 SysFreeString(text);
1940 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
1941 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
1943 BSTR tmp;
1944 HRESULT hres;
1946 tmp = a2bstr(text);
1947 hres = IHTMLStyle_put_cssText(style, tmp);
1948 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
1949 SysFreeString(tmp);
1952 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
1953 const elem_type_t *elem_types, LONG len)
1955 IDispatch *disp;
1956 VARIANT name, index;
1957 DWORD i;
1958 HRESULT hres;
1960 V_VT(&index) = VT_EMPTY;
1961 V_VT(&name) = VT_BSTR;
1962 V_BSTR(&name) = a2bstr(n);
1964 hres = IHTMLElementCollection_item(col, name, index, &disp);
1965 ok(hres == S_OK, "item failed: %08x\n", hres);
1967 test_elem_collection((IUnknown*)disp, elem_types, len);
1968 IDispatch_Release(disp);
1969 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
1970 if(hres != S_OK)
1971 goto cleanup;
1973 V_VT(&index) = VT_I4;
1975 for(i=0; i<len; i++) {
1976 V_I4(&index) = i;
1977 disp = (void*)0xdeadbeef;
1978 hres = IHTMLElementCollection_item(col, name, index, &disp);
1979 ok(hres == S_OK, "item failed: %08x\n", hres);
1980 ok(disp != NULL, "disp == NULL\n");
1981 if(FAILED(hres) || !disp)
1982 continue;
1984 test_elem_type((IUnknown*)disp, elem_types[i]);
1986 IDispatch_Release(disp);
1989 V_I4(&index) = len;
1990 disp = (void*)0xdeadbeef;
1991 hres = IHTMLElementCollection_item(col, name, index, &disp);
1992 ok(hres == S_OK, "item failed: %08x\n", hres);
1993 ok(disp == NULL, "disp != NULL\n");
1995 V_I4(&index) = -1;
1996 disp = (void*)0xdeadbeef;
1997 hres = IHTMLElementCollection_item(col, name, index, &disp);
1998 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1999 ok(disp == NULL, "disp != NULL\n");
2001 cleanup:
2002 SysFreeString(V_BSTR(&name));
2005 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2007 IHTMLElementCollection *col;
2008 IHTMLElement *elem;
2009 IDispatch *disp = (void*)0xdeadbeef;
2010 VARIANT name, index;
2011 HRESULT hres;
2013 hres = IHTMLDocument2_get_all(doc, &col);
2014 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2015 ok(col != NULL, "col == NULL\n");
2016 if(FAILED(hres) || !col)
2017 return NULL;
2019 V_VT(&index) = VT_EMPTY;
2020 V_VT(&name) = VT_BSTR;
2021 V_BSTR(&name) = a2bstr(id);
2023 hres = IHTMLElementCollection_item(col, name, index, &disp);
2024 IHTMLElementCollection_Release(col);
2025 SysFreeString(V_BSTR(&name));
2026 ok(hres == S_OK, "item failed: %08x\n", hres);
2027 if(!expect_success) {
2028 ok(disp == NULL, "disp != NULL\n");
2029 return NULL;
2032 ok(disp != NULL, "disp == NULL\n");
2033 if(!disp)
2034 return NULL;
2036 elem = get_elem_iface((IUnknown*)disp);
2037 IDispatch_Release(disp);
2039 return elem;
2042 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2044 IHTMLDocument3 *doc3;
2045 IHTMLElement *elem;
2046 BSTR tmp;
2047 HRESULT hres;
2049 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2050 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2052 tmp = a2bstr(id);
2053 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2054 SysFreeString(tmp);
2055 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2057 IHTMLDocument3_Release(doc3);
2059 return elem;
2062 static void test_select_elem(IHTMLSelectElement *select)
2064 test_select_type(select, "select-one");
2065 test_select_length(select, 2);
2066 test_select_selidx(select, 0);
2067 test_select_put_selidx(select, 1);
2069 test_select_set_value(select, "val1");
2070 test_select_value(select, "val1");
2072 test_select_get_disabled(select, VARIANT_FALSE);
2073 test_select_set_disabled(select, VARIANT_TRUE);
2074 test_select_set_disabled(select, VARIANT_FALSE);
2077 static void test_create_option_elem(IHTMLDocument2 *doc)
2079 IHTMLOptionElement *option;
2081 option = create_option_elem(doc, "test text", "test value");
2083 test_option_put_text(option, "new text");
2084 test_option_put_value(option, "new value");
2086 IHTMLOptionElement_Release(option);
2089 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2091 IHTMLBodyElement *body;
2092 IHTMLTxtRange *range;
2093 IHTMLElement *elem;
2094 HRESULT hres;
2096 hres = IHTMLDocument2_get_body(doc, &elem);
2097 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2099 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2100 IHTMLElement_Release(elem);
2102 hres = IHTMLBodyElement_createTextRange(body, &range);
2103 IHTMLBodyElement_Release(body);
2104 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2106 return range;
2109 static void test_txtrange(IHTMLDocument2 *doc)
2111 IHTMLTxtRange *body_range, *range, *range2;
2112 IHTMLSelectionObject *selection;
2113 IDispatch *disp_range;
2114 HRESULT hres;
2116 body_range = test_create_body_range(doc);
2118 test_range_text(body_range, "test abc 123\r\nit's text");
2120 hres = IHTMLTxtRange_duplicate(body_range, &range);
2121 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2123 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2124 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2125 test_range_isequal(range, range2, VARIANT_TRUE);
2127 test_range_text(range, "test abc 123\r\nit's text");
2128 test_range_text(body_range, "test abc 123\r\nit's text");
2130 test_range_collapse(range, TRUE);
2131 test_range_isequal(range, range2, VARIANT_FALSE);
2132 test_range_inrange(range, range2, VARIANT_FALSE);
2133 test_range_inrange(range2, range, VARIANT_TRUE);
2134 IHTMLTxtRange_Release(range2);
2136 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2137 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2138 test_range_move(range, characterW, 2, 2);
2139 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2141 test_range_collapse(range, FALSE);
2142 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2144 test_range_collapse(range, FALSE);
2145 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2146 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2147 test_range_move(range, characterW, 2, 2);
2148 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2149 test_range_moveend(range, characterW, -5, -5);
2150 test_range_text(range, NULL);
2151 test_range_moveend(range, characterW, 3, 3);
2152 test_range_text(range, "c 1");
2153 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2154 test_range_collapse(range, TRUE);
2155 test_range_move(range, characterW, 4, 4);
2156 test_range_moveend(range, characterW, 1, 1);
2157 test_range_text(range, " ");
2158 test_range_move(range, wordW, 1, 1);
2159 test_range_moveend(range, characterW, 2, 2);
2160 test_range_text(range, "ab");
2162 IHTMLTxtRange_Release(range);
2164 hres = IHTMLTxtRange_duplicate(body_range, &range);
2165 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2167 test_range_text(range, "test abc 123\r\nit's text");
2168 test_range_move(range, characterW, 3, 3);
2169 test_range_moveend(range, characterW, 1, 1);
2170 test_range_text(range, "t");
2171 test_range_moveend(range, characterW, 3, 3);
2172 test_range_text(range, "t ab");
2173 test_range_moveend(range, characterW, -2, -2);
2174 test_range_text(range, "t ");
2175 test_range_move(range, characterW, 6, 6);
2176 test_range_moveend(range, characterW, 3, 3);
2177 test_range_text(range, "123");
2178 test_range_moveend(range, characterW, 2, 2);
2179 test_range_text(range, "123\r\ni");
2181 IHTMLTxtRange_Release(range);
2183 hres = IHTMLTxtRange_duplicate(body_range, &range);
2184 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2186 test_range_move(range, wordW, 1, 1);
2187 test_range_moveend(range, characterW, 2, 2);
2188 test_range_text(range, "ab");
2190 test_range_move(range, characterW, -2, -2);
2191 test_range_moveend(range, characterW, 2, 2);
2192 test_range_text(range, "t ");
2194 test_range_move(range, wordW, 3, 3);
2195 test_range_move(range, wordW, -2, -2);
2196 test_range_moveend(range, characterW, 2, 2);
2197 test_range_text(range, "ab");
2199 test_range_move(range, characterW, -6, -5);
2200 test_range_moveend(range, characterW, -1, 0);
2201 test_range_moveend(range, characterW, -6, 0);
2202 test_range_move(range, characterW, 2, 2);
2203 test_range_moveend(range, characterW, 2, 2);
2204 test_range_text(range, "st");
2205 test_range_moveend(range, characterW, -6, -4);
2206 test_range_moveend(range, characterW, 2, 2);
2208 IHTMLTxtRange_Release(range);
2210 hres = IHTMLTxtRange_duplicate(body_range, &range);
2211 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2213 test_range_move(range, wordW, 2, 2);
2214 test_range_moveend(range, characterW, 2, 2);
2215 test_range_text(range, "12");
2217 test_range_move(range, characterW, 15, 14);
2218 test_range_move(range, characterW, -2, -2);
2219 test_range_moveend(range, characterW, 3, 2);
2220 test_range_text(range, "t");
2221 test_range_moveend(range, characterW, -1, -1);
2222 test_range_text(range, "t");
2223 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2224 test_range_move(range, characterW, -2, -2);
2225 test_range_moveend(range, characterW, 2, 2);
2226 test_range_text(range, "s ");
2227 test_range_move(range, characterW, 100, 7);
2228 test_range_move(range, wordW, 1, 0);
2229 test_range_move(range, characterW, -2, -2);
2230 test_range_moveend(range, characterW, 3, 2);
2231 test_range_text(range, "t");
2233 IHTMLTxtRange_Release(range);
2235 hres = IHTMLTxtRange_duplicate(body_range, &range);
2236 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2238 test_range_collapse(range, TRUE);
2239 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2240 test_range_put_text(range, "word");
2241 test_range_text(body_range, "wordabc 123\r\nit's text");
2242 test_range_text(range, NULL);
2243 test_range_moveend(range, characterW, 3, 3);
2244 test_range_text(range, "abc");
2245 test_range_movestart(range, characterW, -2, -2);
2246 test_range_text(range, "rdabc");
2247 test_range_movestart(range, characterW, 3, 3);
2248 test_range_text(range, "bc");
2249 test_range_movestart(range, characterW, 4, 4);
2250 test_range_text(range, NULL);
2251 test_range_movestart(range, characterW, -3, -3);
2252 test_range_text(range, "c 1");
2253 test_range_movestart(range, characterW, -7, -6);
2254 test_range_text(range, "wordabc 1");
2255 test_range_movestart(range, characterW, 100, 22);
2256 test_range_text(range, NULL);
2258 IHTMLTxtRange_Release(range);
2259 IHTMLTxtRange_Release(body_range);
2261 hres = IHTMLDocument2_get_selection(doc, &selection);
2262 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2264 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2265 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2266 IHTMLSelectionObject_Release(selection);
2268 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2269 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2270 IDispatch_Release(disp_range);
2272 test_range_text(range, NULL);
2273 test_range_moveend(range, characterW, 3, 3);
2274 test_range_text(range, "wor");
2275 test_range_parent(range, ET_BODY);
2276 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2277 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2278 test_range_move(range, characterW, 3, 3);
2279 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2280 test_range_moveend(range, characterW, -4, -4);
2281 test_range_put_text(range, "abc def ");
2282 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2283 test_range_move(range, wordW, 1, 1);
2284 test_range_movestart(range, characterW, -1, -1);
2285 test_range_text(range, " ");
2286 test_range_move(range, wordW, 1, 1);
2287 test_range_moveend(range, characterW, 3, 3);
2288 test_range_text(range, "def");
2289 test_range_put_text(range, "xyz");
2290 test_range_moveend(range, characterW, 1, 1);
2291 test_range_move(range, wordW, 1, 1);
2292 test_range_moveend(range, characterW, 2, 2);
2293 test_range_text(range, "ab");
2295 IHTMLTxtRange_Release(range);
2298 static void test_txtrange2(IHTMLDocument2 *doc)
2300 IHTMLTxtRange *range;
2302 range = test_create_body_range(doc);
2304 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2305 test_range_move(range, characterW, 5, 5);
2306 test_range_moveend(range, characterW, 1, 1);
2307 test_range_text(range, "2");
2308 test_range_move(range, characterW, -3, -3);
2309 test_range_moveend(range, characterW, 3, 3);
2310 test_range_text(range, "c\r\n\r\n1");
2311 test_range_collapse(range, VARIANT_FALSE);
2312 test_range_moveend(range, characterW, 4, 4);
2313 test_range_text(range, "23");
2314 test_range_moveend(range, characterW, 1, 1);
2315 test_range_text(range, "23\r\n\r\n\r\nd");
2316 test_range_moveend(range, characterW, -1, -1);
2317 test_range_text(range, "23");
2318 test_range_moveend(range, characterW, -1, -1);
2319 test_range_text(range, "23");
2320 test_range_moveend(range, characterW, -2, -2);
2321 test_range_text(range, "2");
2323 IHTMLTxtRange_Release(range);
2326 static void test_compatmode(IHTMLDocument2 *doc)
2328 IHTMLDocument5 *doc5;
2329 BSTR mode;
2330 HRESULT hres;
2332 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2333 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2334 if(FAILED(hres))
2335 return;
2337 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2338 IHTMLDocument5_Release(doc5);
2339 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2340 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", dbgstr_w(mode));
2341 SysFreeString(mode);
2344 static void test_location(IHTMLDocument2 *doc)
2346 IHTMLLocation *location, *location2;
2347 IHTMLWindow2 *window;
2348 ULONG ref;
2349 HRESULT hres;
2351 hres = IHTMLDocument2_get_location(doc, &location);
2352 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2354 hres = IHTMLDocument2_get_location(doc, &location2);
2355 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2357 ok(location == location2, "location != location2\n");
2358 IHTMLLocation_Release(location2);
2360 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2361 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2363 hres = IHTMLWindow2_get_location(window, &location2);
2364 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2365 ok(location == location2, "location != location2\n");
2366 IHTMLLocation_Release(location2);
2368 test_ifaces((IUnknown*)location, location_iids);
2369 test_disp((IUnknown*)location, &IID_IHTMLLocation);
2371 ref = IHTMLLocation_Release(location);
2372 ok(!ref, "location chould be destroyed here\n");
2375 static void test_navigator(IHTMLDocument2 *doc)
2377 IHTMLWindow2 *window;
2378 IOmNavigator *navigator, *navigator2;
2379 ULONG ref;
2380 BSTR bstr;
2381 HRESULT hres;
2383 static const WCHAR v40[] = {'4','.','0'};
2385 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2386 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2388 hres = IHTMLWindow2_get_navigator(window, &navigator);
2389 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2390 ok(navigator != NULL, "navigator == NULL\n");
2391 test_disp((IUnknown*)navigator, &IID_IOmNavigator);
2393 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2394 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2395 ok(navigator != navigator2, "navigator2 != navihgator\n");
2397 IHTMLWindow2_Release(window);
2398 IOmNavigator_Release(navigator2);
2400 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2401 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2402 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", dbgstr_w(bstr));
2403 SysFreeString(bstr);
2405 bstr = NULL;
2406 hres = IOmNavigator_get_platform(navigator, &bstr);
2407 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2408 #ifdef _WIN64
2409 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", dbgstr_w(bstr));
2410 #else
2411 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", dbgstr_w(bstr));
2412 #endif
2413 SysFreeString(bstr);
2415 bstr = NULL;
2416 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2417 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2418 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", dbgstr_w(bstr));
2419 SysFreeString(bstr);
2421 ref = IOmNavigator_Release(navigator);
2422 ok(!ref, "navigator should be destroyed here\n");
2425 static void test_current_style(IHTMLCurrentStyle *current_style)
2427 BSTR str;
2428 HRESULT hres;
2429 VARIANT v;
2431 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle);
2432 test_ifaces((IUnknown*)current_style, cstyle_iids);
2434 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2435 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2436 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", dbgstr_w(str));
2437 SysFreeString(str);
2439 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2440 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2441 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", dbgstr_w(str));
2442 SysFreeString(str);
2444 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
2445 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2446 SysFreeString(str);
2448 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
2449 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
2450 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", dbgstr_w(str));
2451 SysFreeString(str);
2453 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
2454 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
2455 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", dbgstr_w(str));
2456 SysFreeString(str);
2458 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
2459 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2460 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", dbgstr_w(str));
2461 SysFreeString(str);
2463 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
2464 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
2465 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", dbgstr_w(str));
2466 SysFreeString(str);
2468 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
2469 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
2470 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", dbgstr_w(str));
2471 SysFreeString(str);
2473 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
2474 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
2475 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", dbgstr_w(str));
2476 SysFreeString(str);
2478 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
2479 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
2480 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", dbgstr_w(str));
2481 SysFreeString(str);
2483 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
2484 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
2485 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", dbgstr_w(str));
2486 SysFreeString(str);
2488 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
2489 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2490 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", dbgstr_w(str));
2491 SysFreeString(str);
2493 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
2494 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
2495 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", dbgstr_w(str));
2496 SysFreeString(str);
2498 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
2499 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
2500 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", dbgstr_w(str));
2501 SysFreeString(str);
2503 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
2504 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
2505 SysFreeString(str);
2507 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
2508 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
2509 SysFreeString(str);
2511 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
2512 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2513 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2514 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
2515 VariantClear(&v);
2517 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
2518 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
2519 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2520 VariantClear(&v);
2522 hres = IHTMLCurrentStyle_get_left(current_style, &v);
2523 ok(hres == S_OK, "get_left failed: %08x\n", hres);
2524 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2525 VariantClear(&v);
2527 hres = IHTMLCurrentStyle_get_top(current_style, &v);
2528 ok(hres == S_OK, "get_top failed: %08x\n", hres);
2529 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2530 VariantClear(&v);
2532 hres = IHTMLCurrentStyle_get_width(current_style, &v);
2533 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2534 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2535 VariantClear(&v);
2537 hres = IHTMLCurrentStyle_get_height(current_style, &v);
2538 ok(hres == S_OK, "get_height failed: %08x\n", hres);
2539 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2540 VariantClear(&v);
2542 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
2543 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
2544 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2545 VariantClear(&v);
2547 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
2548 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
2549 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2550 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
2551 VariantClear(&v);
2553 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
2554 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
2555 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2556 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", dbgstr_w(V_BSTR(&v)));
2557 VariantClear(&v);
2559 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
2560 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
2561 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2562 VariantClear(&v);
2564 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
2565 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
2566 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2567 VariantClear(&v);
2570 static void test_style2(IHTMLStyle2 *style2)
2572 BSTR str;
2573 HRESULT hres;
2575 str = (void*)0xdeadbeef;
2576 hres = IHTMLStyle2_get_position(style2, &str);
2577 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2578 ok(!str, "str != NULL\n");
2580 str = a2bstr("absolute");
2581 hres = IHTMLStyle2_put_position(style2, str);
2582 ok(hres == S_OK, "put_position failed: %08x\n", hres);
2583 SysFreeString(str);
2585 str = NULL;
2586 hres = IHTMLStyle2_get_position(style2, &str);
2587 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2588 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", dbgstr_w(str));
2589 SysFreeString(str);
2592 static void test_style4(IHTMLStyle4 *style4)
2594 HRESULT hres;
2595 VARIANT v;
2596 VARIANT vdefault;
2598 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
2599 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
2601 V_VT(&v) = VT_BSTR;
2602 V_BSTR(&v) = a2bstr("10px");
2603 hres = IHTMLStyle4_put_minHeight(style4, v);
2604 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
2605 VariantClear(&v);
2607 hres = IHTMLStyle4_get_minHeight(style4, &v);
2608 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
2609 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2610 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", dbgstr_w(V_BSTR(&v)));
2612 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
2613 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
2614 VariantClear(&vdefault);
2617 static void test_default_style(IHTMLStyle *style)
2619 IHTMLStyle2 *style2;
2620 IHTMLStyle4 *style4;
2621 VARIANT_BOOL b;
2622 VARIANT v;
2623 BSTR str;
2624 HRESULT hres;
2625 float f;
2626 BSTR sOverflowDefault;
2627 BSTR sDefault;
2628 VARIANT vDefault;
2630 test_disp((IUnknown*)style, &DIID_DispHTMLStyle);
2631 test_ifaces((IUnknown*)style, style_iids);
2633 test_style_csstext(style, NULL);
2635 hres = IHTMLStyle_get_position(style, &str);
2636 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2637 ok(!str, "str=%s\n", dbgstr_w(str));
2639 V_VT(&v) = VT_NULL;
2640 hres = IHTMLStyle_get_marginRight(style, &v);
2641 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
2642 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
2643 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", dbgstr_w(V_BSTR(&v)));
2645 V_VT(&v) = VT_NULL;
2646 hres = IHTMLStyle_get_marginLeft(style, &v);
2647 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
2648 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
2649 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", dbgstr_w(V_BSTR(&v)));
2651 str = (void*)0xdeadbeef;
2652 hres = IHTMLStyle_get_fontFamily(style, &str);
2653 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2654 ok(!str, "fontFamily = %s\n", dbgstr_w(str));
2656 str = (void*)0xdeadbeef;
2657 hres = IHTMLStyle_get_fontWeight(style, &str);
2658 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2659 ok(!str, "fontWeight = %s\n", dbgstr_w(str));
2661 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
2662 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2664 str = a2bstr("test");
2665 hres = IHTMLStyle_put_fontWeight(style, str);
2666 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
2667 SysFreeString(str);
2669 str = a2bstr("bold");
2670 hres = IHTMLStyle_put_fontWeight(style, str);
2671 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2672 SysFreeString(str);
2674 str = a2bstr("bolder");
2675 hres = IHTMLStyle_put_fontWeight(style, str);
2676 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2677 SysFreeString(str);
2679 str = a2bstr("lighter");
2680 hres = IHTMLStyle_put_fontWeight(style, str);
2681 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2682 SysFreeString(str);
2684 str = a2bstr("100");
2685 hres = IHTMLStyle_put_fontWeight(style, str);
2686 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2687 SysFreeString(str);
2689 str = a2bstr("200");
2690 hres = IHTMLStyle_put_fontWeight(style, str);
2691 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2692 SysFreeString(str);
2694 str = a2bstr("300");
2695 hres = IHTMLStyle_put_fontWeight(style, str);
2696 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2697 SysFreeString(str);
2699 str = a2bstr("400");
2700 hres = IHTMLStyle_put_fontWeight(style, str);
2701 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2702 SysFreeString(str);
2704 str = a2bstr("500");
2705 hres = IHTMLStyle_put_fontWeight(style, str);
2706 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2707 SysFreeString(str);
2709 str = a2bstr("600");
2710 hres = IHTMLStyle_put_fontWeight(style, str);
2711 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2712 SysFreeString(str);
2714 str = a2bstr("700");
2715 hres = IHTMLStyle_put_fontWeight(style, str);
2716 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2717 SysFreeString(str);
2719 str = a2bstr("800");
2720 hres = IHTMLStyle_put_fontWeight(style, str);
2721 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2722 SysFreeString(str);
2724 str = a2bstr("900");
2725 hres = IHTMLStyle_put_fontWeight(style, str);
2726 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2727 SysFreeString(str);
2729 hres = IHTMLStyle_get_fontWeight(style, &str);
2730 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2731 ok(!strcmp_wa(str, "900"), "str != style900\n");
2732 SysFreeString(str);
2734 hres = IHTMLStyle_put_fontWeight(style, sDefault);
2735 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
2736 SysFreeString(sDefault);
2738 /* font Variant */
2739 hres = IHTMLStyle_get_fontVariant(style, NULL);
2740 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
2742 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
2743 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2745 str = a2bstr("test");
2746 hres = IHTMLStyle_put_fontVariant(style, str);
2747 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
2748 SysFreeString(str);
2750 str = a2bstr("small-caps");
2751 hres = IHTMLStyle_put_fontVariant(style, str);
2752 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
2753 SysFreeString(str);
2755 str = a2bstr("normal");
2756 hres = IHTMLStyle_put_fontVariant(style, str);
2757 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
2758 SysFreeString(str);
2760 hres = IHTMLStyle_put_fontVariant(style, sDefault);
2761 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
2762 SysFreeString(sDefault);
2764 str = (void*)0xdeadbeef;
2765 hres = IHTMLStyle_get_display(style, &str);
2766 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2767 ok(!str, "display = %s\n", dbgstr_w(str));
2769 str = (void*)0xdeadbeef;
2770 hres = IHTMLStyle_get_visibility(style, &str);
2771 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
2772 ok(!str, "visibility = %s\n", dbgstr_w(str));
2774 V_VT(&v) = VT_NULL;
2775 hres = IHTMLStyle_get_fontSize(style, &v);
2776 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
2777 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
2778 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", dbgstr_w(V_BSTR(&v)));
2780 V_VT(&v) = VT_NULL;
2781 hres = IHTMLStyle_get_color(style, &v);
2782 ok(hres == S_OK, "get_color failed: %08x\n", hres);
2783 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
2784 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", dbgstr_w(V_BSTR(&v)));
2786 b = 0xfefe;
2787 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
2788 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
2789 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
2791 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
2792 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
2793 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
2795 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
2796 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
2797 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
2799 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
2800 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
2802 b = 0xfefe;
2803 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
2804 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
2805 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
2807 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
2808 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
2809 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
2811 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
2812 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
2813 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
2815 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
2816 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
2818 b = 0xfefe;
2819 hres = IHTMLStyle_get_textDecorationNone(style, &b);
2820 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
2821 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
2823 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
2824 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
2825 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
2827 hres = IHTMLStyle_get_textDecorationNone(style, &b);
2828 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
2829 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
2831 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
2832 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
2834 b = 0xfefe;
2835 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
2836 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
2837 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
2839 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
2840 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
2841 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
2843 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
2844 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
2845 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
2847 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
2848 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
2850 b = 0xfefe;
2851 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
2852 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
2853 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
2855 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
2856 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
2857 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
2859 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
2860 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
2861 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
2863 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
2864 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
2866 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
2867 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2869 str = a2bstr("invalid");
2870 hres = IHTMLStyle_put_textDecoration(style, str);
2871 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
2872 SysFreeString(str);
2874 str = a2bstr("none");
2875 hres = IHTMLStyle_put_textDecoration(style, str);
2876 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2877 SysFreeString(str);
2879 str = a2bstr("underline");
2880 hres = IHTMLStyle_put_textDecoration(style, str);
2881 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2882 SysFreeString(str);
2884 str = a2bstr("overline");
2885 hres = IHTMLStyle_put_textDecoration(style, str);
2886 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2887 SysFreeString(str);
2889 str = a2bstr("line-through");
2890 hres = IHTMLStyle_put_textDecoration(style, str);
2891 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2892 SysFreeString(str);
2894 str = a2bstr("blink");
2895 hres = IHTMLStyle_put_textDecoration(style, str);
2896 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2897 SysFreeString(str);
2899 hres = IHTMLStyle_get_textDecoration(style, &str);
2900 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2901 ok(!strcmp_wa(str, "blink"), "str != blink\n");
2902 SysFreeString(str);
2904 hres = IHTMLStyle_put_textDecoration(style, sDefault);
2905 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
2906 SysFreeString(sDefault);
2908 hres = IHTMLStyle_get_posWidth(style, NULL);
2909 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
2911 hres = IHTMLStyle_get_posWidth(style, &f);
2912 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
2913 ok(f == 0.0f, "f = %f\n", f);
2915 V_VT(&v) = VT_EMPTY;
2916 hres = IHTMLStyle_get_width(style, &v);
2917 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2918 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
2919 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
2921 hres = IHTMLStyle_put_posWidth(style, 2.2);
2922 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
2924 hres = IHTMLStyle_get_posWidth(style, &f);
2925 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
2926 ok(f == 2.0f ||
2927 f == 2.2f, /* IE8 */
2928 "f = %f\n", f);
2930 V_VT(&v) = VT_BSTR;
2931 V_BSTR(&v) = a2bstr("auto");
2932 hres = IHTMLStyle_put_width(style, v);
2933 ok(hres == S_OK, "put_width failed: %08x\n", hres);
2934 VariantClear(&v);
2936 V_VT(&v) = VT_EMPTY;
2937 hres = IHTMLStyle_get_width(style, &v);
2938 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2939 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
2940 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", dbgstr_w(V_BSTR(&v)));
2941 VariantClear(&v);
2943 /* margin tests */
2944 str = (void*)0xdeadbeef;
2945 hres = IHTMLStyle_get_margin(style, &str);
2946 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
2947 ok(!str, "margin = %s\n", dbgstr_w(str));
2949 str = a2bstr("1");
2950 hres = IHTMLStyle_put_margin(style, str);
2951 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
2952 SysFreeString(str);
2954 hres = IHTMLStyle_get_margin(style, &str);
2955 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
2956 todo_wine
2957 ok(!strcmp_wa(str, "1px"), "margin = %s\n", dbgstr_w(str));
2959 hres = IHTMLStyle_put_margin(style, NULL);
2960 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
2962 str = NULL;
2963 hres = IHTMLStyle_get_border(style, &str);
2964 ok(hres == S_OK, "get_border failed: %08x\n", hres);
2965 ok(!str || !*str, "str is not empty\n");
2966 SysFreeString(str);
2968 str = a2bstr("1px");
2969 hres = IHTMLStyle_put_border(style, str);
2970 ok(hres == S_OK, "put_border failed: %08x\n", hres);
2971 SysFreeString(str);
2973 V_VT(&v) = VT_EMPTY;
2974 hres = IHTMLStyle_get_left(style, &v);
2975 ok(hres == S_OK, "get_left failed: %08x\n", hres);
2976 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
2977 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
2978 VariantClear(&v);
2980 /* Test posLeft */
2981 hres = IHTMLStyle_get_posLeft(style, NULL);
2982 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
2984 f = 1.0f;
2985 hres = IHTMLStyle_get_posLeft(style, &f);
2986 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
2987 ok(f == 0.0, "expected 0.0 got %f\n", f);
2989 hres = IHTMLStyle_put_posLeft(style, 4.9f);
2990 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
2992 hres = IHTMLStyle_get_posLeft(style, &f);
2993 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
2994 ok(f == 4.0 ||
2995 f == 4.9f, /* IE8 */
2996 "expected 4.0 or 4.9 (IE8) got %f\n", f);
2998 /* Ensure left is updated correctly. */
2999 V_VT(&v) = VT_EMPTY;
3000 hres = IHTMLStyle_get_left(style, &v);
3001 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3002 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3003 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3004 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3005 "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
3006 VariantClear(&v);
3008 /* Test left */
3009 V_VT(&v) = VT_BSTR;
3010 V_BSTR(&v) = a2bstr("3px");
3011 hres = IHTMLStyle_put_left(style, v);
3012 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3013 VariantClear(&v);
3015 hres = IHTMLStyle_get_posLeft(style, &f);
3016 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3017 ok(f == 3.0, "expected 3.0 got %f\n", f);
3019 V_VT(&v) = VT_EMPTY;
3020 hres = IHTMLStyle_get_left(style, &v);
3021 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3022 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3023 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
3024 VariantClear(&v);
3026 V_VT(&v) = VT_NULL;
3027 hres = IHTMLStyle_put_left(style, v);
3028 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3030 V_VT(&v) = VT_EMPTY;
3031 hres = IHTMLStyle_get_left(style, &v);
3032 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3033 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3034 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3035 VariantClear(&v);
3037 V_VT(&v) = VT_EMPTY;
3038 hres = IHTMLStyle_get_top(style, &v);
3039 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3040 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3041 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3042 VariantClear(&v);
3044 /* Test posTop */
3045 hres = IHTMLStyle_get_posTop(style, NULL);
3046 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3048 f = 1.0f;
3049 hres = IHTMLStyle_get_posTop(style, &f);
3050 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3051 ok(f == 0.0, "expected 0.0 got %f\n", f);
3053 hres = IHTMLStyle_put_posTop(style, 4.9f);
3054 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3056 hres = IHTMLStyle_get_posTop(style, &f);
3057 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3058 ok(f == 4.0 ||
3059 f == 4.9f, /* IE8 */
3060 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3062 V_VT(&v) = VT_BSTR;
3063 V_BSTR(&v) = a2bstr("3px");
3064 hres = IHTMLStyle_put_top(style, v);
3065 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3066 VariantClear(&v);
3068 V_VT(&v) = VT_EMPTY;
3069 hres = IHTMLStyle_get_top(style, &v);
3070 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3071 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3072 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
3073 VariantClear(&v);
3075 hres = IHTMLStyle_get_posTop(style, &f);
3076 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3077 ok(f == 3.0, "expected 3.0 got %f\n", f);
3079 V_VT(&v) = VT_NULL;
3080 hres = IHTMLStyle_put_top(style, v);
3081 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3083 V_VT(&v) = VT_EMPTY;
3084 hres = IHTMLStyle_get_top(style, &v);
3085 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3086 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3087 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3088 VariantClear(&v);
3090 /* Test posHeight */
3091 hres = IHTMLStyle_get_posHeight(style, NULL);
3092 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3094 V_VT(&v) = VT_EMPTY;
3095 hres = IHTMLStyle_get_height(style, &v);
3096 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3097 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3098 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3099 VariantClear(&v);
3101 f = 1.0f;
3102 hres = IHTMLStyle_get_posHeight(style, &f);
3103 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3104 ok(f == 0.0, "expected 0.0 got %f\n", f);
3106 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3107 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3109 hres = IHTMLStyle_get_posHeight(style, &f);
3110 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3111 ok(f == 4.0 ||
3112 f == 4.9f, /* IE8 */
3113 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3115 V_VT(&v) = VT_BSTR;
3116 V_BSTR(&v) = a2bstr("64px");
3117 hres = IHTMLStyle_put_height(style, v);
3118 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3119 VariantClear(&v);
3121 V_VT(&v) = VT_EMPTY;
3122 hres = IHTMLStyle_get_height(style, &v);
3123 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3124 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3125 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
3126 VariantClear(&v);
3128 hres = IHTMLStyle_get_posHeight(style, &f);
3129 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3130 ok(f == 64.0, "expected 64.0 got %f\n", f);
3132 str = (void*)0xdeadbeef;
3133 hres = IHTMLStyle_get_cursor(style, &str);
3134 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3135 ok(!str, "get_cursor != NULL\n");
3136 SysFreeString(str);
3138 str = a2bstr("default");
3139 hres = IHTMLStyle_put_cursor(style, str);
3140 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3141 SysFreeString(str);
3143 str = NULL;
3144 hres = IHTMLStyle_get_cursor(style, &str);
3145 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3146 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", dbgstr_w(str));
3147 SysFreeString(str);
3149 V_VT(&v) = VT_EMPTY;
3150 hres = IHTMLStyle_get_verticalAlign(style, &v);
3151 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3152 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3153 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3154 VariantClear(&v);
3156 V_VT(&v) = VT_BSTR;
3157 V_BSTR(&v) = a2bstr("middle");
3158 hres = IHTMLStyle_put_verticalAlign(style, v);
3159 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3160 VariantClear(&v);
3162 V_VT(&v) = VT_EMPTY;
3163 hres = IHTMLStyle_get_verticalAlign(style, &v);
3164 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3165 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3166 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
3167 VariantClear(&v);
3169 str = (void*)0xdeadbeef;
3170 hres = IHTMLStyle_get_textAlign(style, &str);
3171 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3172 ok(!str, "textAlign != NULL\n");
3174 str = a2bstr("center");
3175 hres = IHTMLStyle_put_textAlign(style, str);
3176 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3177 SysFreeString(str);
3179 str = NULL;
3180 hres = IHTMLStyle_get_textAlign(style, &str);
3181 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3182 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", dbgstr_w(V_BSTR(&v)));
3183 SysFreeString(str);
3185 str = (void*)0xdeadbeef;
3186 hres = IHTMLStyle_get_filter(style, &str);
3187 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3188 ok(!str, "filter != NULL\n");
3190 str = a2bstr("alpha(opacity=100)");
3191 hres = IHTMLStyle_put_filter(style, str);
3192 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3193 SysFreeString(str);
3195 V_VT(&v) = VT_EMPTY;
3196 hres = IHTMLStyle_get_zIndex(style, &v);
3197 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3198 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3199 ok(!V_I4(&v), "V_I4(v) != 0\n");
3200 VariantClear(&v);
3202 V_VT(&v) = VT_BSTR;
3203 V_BSTR(&v) = a2bstr("1");
3204 hres = IHTMLStyle_put_zIndex(style, v);
3205 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3206 VariantClear(&v);
3208 V_VT(&v) = VT_EMPTY;
3209 hres = IHTMLStyle_get_zIndex(style, &v);
3210 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3211 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3212 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3213 VariantClear(&v);
3215 /* fontStyle */
3216 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3217 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3219 str = a2bstr("test");
3220 hres = IHTMLStyle_put_fontStyle(style, str);
3221 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3222 SysFreeString(str);
3224 str = a2bstr("italic");
3225 hres = IHTMLStyle_put_fontStyle(style, str);
3226 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3227 SysFreeString(str);
3229 str = a2bstr("oblique");
3230 hres = IHTMLStyle_put_fontStyle(style, str);
3231 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3232 SysFreeString(str);
3234 str = a2bstr("normal");
3235 hres = IHTMLStyle_put_fontStyle(style, str);
3236 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3237 SysFreeString(str);
3239 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3240 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3241 SysFreeString(sDefault);
3243 /* overflow */
3244 hres = IHTMLStyle_get_overflow(style, NULL);
3245 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3247 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3248 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3250 str = a2bstr("test");
3251 hres = IHTMLStyle_put_overflow(style, str);
3252 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
3253 SysFreeString(str);
3255 str = a2bstr("visible");
3256 hres = IHTMLStyle_put_overflow(style, str);
3257 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3258 SysFreeString(str);
3260 str = a2bstr("scroll");
3261 hres = IHTMLStyle_put_overflow(style, str);
3262 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3263 SysFreeString(str);
3265 str = a2bstr("hidden");
3266 hres = IHTMLStyle_put_overflow(style, str);
3267 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3268 SysFreeString(str);
3270 str = a2bstr("auto");
3271 hres = IHTMLStyle_put_overflow(style, str);
3272 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3273 SysFreeString(str);
3275 hres = IHTMLStyle_get_overflow(style, &str);
3276 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3277 ok(!strcmp_wa(str, "auto"), "str=%s\n", dbgstr_w(str));
3278 SysFreeString(str);
3280 /* restore overflow default */
3281 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
3282 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3283 SysFreeString(sOverflowDefault);
3285 /* Attribute Tests*/
3286 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
3287 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3289 str = a2bstr("position");
3290 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
3291 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3293 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3294 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3295 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3296 VariantClear(&v);
3298 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
3299 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
3301 V_VT(&v) = VT_BSTR;
3302 V_BSTR(&v) = a2bstr("absolute");
3303 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3304 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3305 VariantClear(&v);
3307 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3308 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3309 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3310 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", dbgstr_w(V_BSTR(&v)));
3311 VariantClear(&v);
3313 V_VT(&v) = VT_BSTR;
3314 V_BSTR(&v) = NULL;
3315 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3316 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3317 VariantClear(&v);
3319 SysFreeString(str);
3321 str = a2bstr("borderLeftStyle");
3322 test_border_styles(style, str);
3323 SysFreeString(str);
3325 str = a2bstr("borderbottomstyle");
3326 test_border_styles(style, str);
3327 SysFreeString(str);
3329 str = a2bstr("borderrightstyle");
3330 test_border_styles(style, str);
3331 SysFreeString(str);
3333 str = a2bstr("bordertopstyle");
3334 test_border_styles(style, str);
3335 SysFreeString(str);
3337 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
3338 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3340 str = a2bstr("none dotted dashed solid");
3341 hres = IHTMLStyle_put_borderStyle(style, str);
3342 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3343 SysFreeString(str);
3345 str = a2bstr("none dotted dashed solid");
3346 hres = IHTMLStyle_get_borderStyle(style, &str);
3347 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3348 ok(!strcmp_wa(str, "none dotted dashed solid"),
3349 "expected (none dotted dashed solid) = (%s)\n", dbgstr_w(V_BSTR(&v)));
3350 SysFreeString(str);
3352 str = a2bstr("double groove ridge inset");
3353 hres = IHTMLStyle_put_borderStyle(style, str);
3354 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3355 SysFreeString(str);
3357 str = a2bstr("window-inset outset ridge inset");
3358 hres = IHTMLStyle_put_borderStyle(style, str);
3359 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3360 SysFreeString(str);
3362 str = a2bstr("window-inset");
3363 hres = IHTMLStyle_put_borderStyle(style, str);
3364 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3365 SysFreeString(str);
3367 str = a2bstr("none none none none none");
3368 hres = IHTMLStyle_put_borderStyle(style, str);
3369 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3370 SysFreeString(str);
3372 str = a2bstr("invalid none none none");
3373 hres = IHTMLStyle_put_borderStyle(style, str);
3374 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3375 SysFreeString(str);
3377 str = a2bstr("none invalid none none");
3378 hres = IHTMLStyle_put_borderStyle(style, str);
3379 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3380 SysFreeString(str);
3382 hres = IHTMLStyle_put_borderStyle(style, sDefault);
3383 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3384 SysFreeString(sDefault);
3386 /* backgoundColor */
3387 hres = IHTMLStyle_get_backgroundColor(style, &v);
3388 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
3389 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3390 ok(!V_BSTR(&v), "str=%s\n", dbgstr_w(V_BSTR(&v)));
3391 VariantClear(&v);
3393 /* PaddingLeft */
3394 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
3395 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3397 V_VT(&v) = VT_BSTR;
3398 V_BSTR(&v) = a2bstr("10");
3399 hres = IHTMLStyle_put_paddingLeft(style, v);
3400 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3401 VariantClear(&v);
3403 hres = IHTMLStyle_get_paddingLeft(style, &v);
3404 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3405 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", dbgstr_w(V_BSTR(&v)));
3407 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
3408 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3410 /* BackgroundRepeat */
3411 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
3412 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3414 str = a2bstr("invalid");
3415 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3416 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
3417 SysFreeString(str);
3419 str = a2bstr("repeat");
3420 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3421 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3422 SysFreeString(str);
3424 str = a2bstr("no-repeat");
3425 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3426 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3427 SysFreeString(str);
3429 str = a2bstr("repeat-x");
3430 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3431 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3432 SysFreeString(str);
3434 str = a2bstr("repeat-y");
3435 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3436 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3437 SysFreeString(str);
3439 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
3440 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3441 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", dbgstr_w(str));
3442 SysFreeString(str);
3444 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
3445 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3446 SysFreeString(sDefault);
3448 /* BorderColor */
3449 hres = IHTMLStyle_get_borderColor(style, &sDefault);
3450 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3452 str = a2bstr("red green red blue");
3453 hres = IHTMLStyle_put_borderColor(style, str);
3454 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3455 SysFreeString(str);
3457 hres = IHTMLStyle_get_borderColor(style, &str);
3458 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3459 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", dbgstr_w(str));
3460 SysFreeString(str);
3462 hres = IHTMLStyle_put_borderColor(style, sDefault);
3463 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3464 SysFreeString(sDefault);
3466 /* BorderLeft */
3467 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
3468 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
3470 str = a2bstr("thick dotted red");
3471 hres = IHTMLStyle_put_borderLeft(style, str);
3472 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3473 SysFreeString(str);
3475 /* IHTMLStyle_get_borderLeft appears to have a bug where
3476 it returns the first letter of the color. So we check
3477 each style individually.
3479 V_BSTR(&v) = NULL;
3480 hres = IHTMLStyle_get_borderLeftColor(style, &v);
3481 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3482 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", dbgstr_w(V_BSTR(&v)));
3483 VariantClear(&v);
3485 V_BSTR(&v) = NULL;
3486 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
3487 todo_wine ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3488 todo_wine ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", dbgstr_w(V_BSTR(&v)));
3489 VariantClear(&v);
3491 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
3492 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3493 ok(!strcmp_wa(str, "dotted"), "str=%s\n", dbgstr_w(str));
3494 SysFreeString(str);
3496 hres = IHTMLStyle_put_borderLeft(style, sDefault);
3497 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3498 SysFreeString(sDefault);
3500 /* backgroundPositionX */
3501 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
3502 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3504 V_VT(&v) = VT_BSTR;
3505 V_BSTR(&v) = a2bstr("10px");
3506 hres = IHTMLStyle_put_backgroundPositionX(style, v);
3507 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3508 VariantClear(&v);
3510 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
3511 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3512 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3513 VariantClear(&v);
3515 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
3516 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3517 VariantClear(&vDefault);
3519 /* backgroundPositionY */
3520 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
3521 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
3523 V_VT(&v) = VT_BSTR;
3524 V_BSTR(&v) = a2bstr("10px");
3525 hres = IHTMLStyle_put_backgroundPositionY(style, v);
3526 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
3527 VariantClear(&v);
3529 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
3530 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
3531 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3532 VariantClear(&v);
3534 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
3535 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
3536 VariantClear(&vDefault);
3538 /* borderTopWidth */
3539 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
3540 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
3542 V_VT(&v) = VT_BSTR;
3543 V_BSTR(&v) = a2bstr("10px");
3544 hres = IHTMLStyle_put_borderTopWidth(style, v);
3545 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
3546 VariantClear(&v);
3548 hres = IHTMLStyle_get_borderTopWidth(style, &v);
3549 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
3550 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", dbgstr_w(V_BSTR(&v)));
3551 VariantClear(&v);
3553 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
3554 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
3555 VariantClear(&vDefault);
3557 /* borderRightWidth */
3558 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
3559 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
3561 V_VT(&v) = VT_BSTR;
3562 V_BSTR(&v) = a2bstr("10");
3563 hres = IHTMLStyle_put_borderRightWidth(style, v);
3564 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
3565 VariantClear(&v);
3567 hres = IHTMLStyle_get_borderRightWidth(style, &v);
3568 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
3569 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", dbgstr_w(V_BSTR(&v)));
3570 VariantClear(&v);
3572 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
3573 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
3574 VariantClear(&vDefault);
3576 /* borderBottomWidth */
3577 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
3578 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
3580 V_VT(&v) = VT_BSTR;
3581 V_BSTR(&v) = a2bstr("10");
3582 hres = IHTMLStyle_put_borderBottomWidth(style, v);
3583 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
3584 VariantClear(&v);
3586 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
3587 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
3588 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", dbgstr_w(V_BSTR(&v)));
3589 VariantClear(&v);
3591 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
3592 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
3593 VariantClear(&vDefault);
3595 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
3596 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
3597 if(SUCCEEDED(hres)) {
3598 test_style2(style2);
3599 IHTMLStyle2_Release(style2);
3602 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
3603 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
3604 if(SUCCEEDED(hres)) {
3605 test_style4(style4);
3606 IHTMLStyle4_Release(style4);
3610 static void test_set_csstext(IHTMLStyle *style)
3612 VARIANT v;
3613 HRESULT hres;
3615 test_style_set_csstext(style, "background-color: black;");
3617 hres = IHTMLStyle_get_backgroundColor(style, &v);
3618 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
3619 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3620 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", dbgstr_w(V_BSTR(&v)));
3621 VariantClear(&v);
3624 static void test_default_selection(IHTMLDocument2 *doc)
3626 IHTMLSelectionObject *selection;
3627 IHTMLTxtRange *range;
3628 IDispatch *disp;
3629 BSTR str;
3630 HRESULT hres;
3632 hres = IHTMLDocument2_get_selection(doc, &selection);
3633 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
3635 hres = IHTMLSelectionObject_get_type(selection, &str);
3636 ok(hres == S_OK, "get_type failed: %08x\n", hres);
3637 ok(!strcmp_wa(str, "None"), "type = %s\n", dbgstr_w(str));
3638 SysFreeString(str);
3640 hres = IHTMLSelectionObject_createRange(selection, &disp);
3641 IHTMLSelectionObject_Release(selection);
3642 ok(hres == S_OK, "createRange failed: %08x\n", hres);
3644 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
3645 IDispatch_Release(disp);
3646 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
3648 test_range_text(range, NULL);
3649 IHTMLTxtRange_Release(range);
3652 static void test_default_body(IHTMLBodyElement *body)
3654 LONG l;
3655 BSTR bstr;
3656 HRESULT hres;
3657 VARIANT v;
3658 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
3659 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
3661 bstr = (void*)0xdeadbeef;
3662 hres = IHTMLBodyElement_get_background(body, &bstr);
3663 ok(hres == S_OK, "get_background failed: %08x\n", hres);
3664 ok(bstr == NULL, "bstr != NULL\n");
3666 l = elem_get_scroll_height((IUnknown*)body);
3667 ok(l != -1, "scrollHeight == -1\n");
3668 l = elem_get_scroll_width((IUnknown*)body);
3669 ok(l != -1, "scrollWidth == -1\n");
3670 l = elem_get_scroll_top((IUnknown*)body);
3671 ok(!l, "scrollTop = %d\n", l);
3672 elem_get_scroll_left((IUnknown*)body);
3674 /* get_text tests */
3675 hres = IHTMLBodyElement_get_text(body, &v);
3676 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
3677 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
3678 ok(bstr == NULL, "bstr != NULL\n");
3681 /* get_text - Invalid Text */
3682 V_VT(&v) = VT_BSTR;
3683 V_BSTR(&v) = SysAllocString(sTextInvalid);
3684 hres = IHTMLBodyElement_put_text(body, v);
3685 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
3686 VariantClear(&v);
3688 V_VT(&v) = VT_NULL;
3689 hres = IHTMLBodyElement_get_text(body, &v);
3690 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
3691 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
3692 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
3693 VariantClear(&v);
3695 /* get_text - Valid Text */
3696 V_VT(&v) = VT_BSTR;
3697 V_BSTR(&v) = SysAllocString(sBodyText);
3698 hres = IHTMLBodyElement_put_text(body, v);
3699 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
3700 VariantClear(&v);
3702 V_VT(&v) = VT_NULL;
3703 hres = IHTMLBodyElement_get_text(body, &v);
3704 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
3705 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
3706 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
3707 VariantClear(&v);
3710 static void test_body_funs(IHTMLBodyElement *body)
3712 static WCHAR sRed[] = {'r','e','d',0};
3713 VARIANT vbg;
3714 VARIANT vDefaultbg;
3715 HRESULT hres;
3717 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
3718 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
3719 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
3721 V_VT(&vbg) = VT_BSTR;
3722 V_BSTR(&vbg) = SysAllocString(sRed);
3723 hres = IHTMLBodyElement_put_bgColor(body, vbg);
3724 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
3725 VariantClear(&vbg);
3727 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
3728 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
3729 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
3730 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", dbgstr_w(V_BSTR(&vbg)));
3731 VariantClear(&vbg);
3733 /* Restore Originial */
3734 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
3735 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
3736 VariantClear(&vDefaultbg);
3739 static void test_window(IHTMLDocument2 *doc)
3741 IHTMLWindow2 *window, *window2, *self;
3742 IHTMLDocument2 *doc2 = NULL;
3743 IDispatch *disp;
3744 HRESULT hres;
3746 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3747 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3748 test_ifaces((IUnknown*)window, window_iids);
3749 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2);
3751 hres = IHTMLWindow2_get_document(window, &doc2);
3752 ok(hres == S_OK, "get_document failed: %08x\n", hres);
3753 ok(doc2 != NULL, "doc2 == NULL\n");
3755 IHTMLDocument_Release(doc2);
3757 hres = IHTMLWindow2_get_window(window, &window2);
3758 ok(hres == S_OK, "get_window failed: %08x\n", hres);
3759 ok(window2 != NULL, "window2 == NULL\n");
3761 hres = IHTMLWindow2_get_self(window, &self);
3762 ok(hres == S_OK, "get_self failed: %08x\n", hres);
3763 ok(window2 != NULL, "self == NULL\n");
3765 ok(self == window2, "self != window2\n");
3767 IHTMLWindow2_Release(window2);
3768 IHTMLWindow2_Release(self);
3770 disp = NULL;
3771 hres = IHTMLDocument2_get_Script(doc, &disp);
3772 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
3773 ok(disp == (void*)window, "disp != window\n");
3774 IDispatch_Release(disp);
3776 IHTMLWindow2_Release(window);
3779 static void test_defaults(IHTMLDocument2 *doc)
3781 IHTMLStyleSheetsCollection *stylesheetcol;
3782 IHTMLCurrentStyle *cstyle;
3783 IHTMLBodyElement *body;
3784 IHTMLElement2 *elem2;
3785 IHTMLElement *elem;
3786 IHTMLStyle *style;
3787 LONG l;
3788 HRESULT hres;
3789 IHTMLElementCollection *collection;
3791 hres = IHTMLDocument2_get_body(doc, &elem);
3792 ok(hres == S_OK, "get_body failed: %08x\n", hres);
3794 hres = IHTMLDocument2_get_images(doc, NULL);
3795 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
3797 hres = IHTMLDocument2_get_images(doc, &collection);
3798 ok(hres == S_OK, "get_images failed: %08x\n", hres);
3799 if(hres == S_OK)
3801 test_elem_collection((IUnknown*)collection, NULL, 0);
3802 IHTMLElementCollection_Release(collection);
3805 hres = IHTMLDocument2_get_applets(doc, NULL);
3806 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
3808 hres = IHTMLDocument2_get_applets(doc, &collection);
3809 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
3810 if(hres == S_OK)
3812 test_elem_collection((IUnknown*)collection, NULL, 0);
3813 IHTMLElementCollection_Release(collection);
3816 hres = IHTMLDocument2_get_links(doc, NULL);
3817 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
3819 hres = IHTMLDocument2_get_links(doc, &collection);
3820 ok(hres == S_OK, "get_links failed: %08x\n", hres);
3821 if(hres == S_OK)
3823 test_elem_collection((IUnknown*)collection, NULL, 0);
3824 IHTMLElementCollection_Release(collection);
3827 hres = IHTMLDocument2_get_forms(doc, NULL);
3828 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
3830 hres = IHTMLDocument2_get_forms(doc, &collection);
3831 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
3832 if(hres == S_OK)
3834 test_elem_collection((IUnknown*)collection, NULL, 0);
3835 IHTMLElementCollection_Release(collection);
3838 hres = IHTMLDocument2_get_anchors(doc, NULL);
3839 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
3841 hres = IHTMLDocument2_get_anchors(doc, &collection);
3842 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
3843 if(hres == S_OK)
3845 test_elem_collection((IUnknown*)collection, NULL, 0);
3846 IHTMLElementCollection_Release(collection);
3849 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3850 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
3851 test_default_body(body);
3852 test_body_funs(body);
3853 IHTMLBodyElement_Release(body);
3855 hres = IHTMLElement_get_style(elem, &style);
3856 ok(hres == S_OK, "get_style failed: %08x\n", hres);
3858 test_default_style(style);
3859 test_window(doc);
3860 test_compatmode(doc);
3861 test_location(doc);
3862 test_navigator(doc);
3864 elem2 = get_elem2_iface((IUnknown*)elem);
3865 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
3866 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
3867 if(SUCCEEDED(hres)) {
3868 test_current_style(cstyle);
3869 IHTMLCurrentStyle_Release(cstyle);
3871 IHTMLElement2_Release(elem2);
3873 IHTMLElement_Release(elem);
3875 test_set_csstext(style);
3876 IHTMLStyle_Release(style);
3878 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
3879 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
3881 l = 0xdeadbeef;
3882 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
3883 ok(hres == S_OK, "get_length failed: %08x\n", hres);
3884 ok(l == 0, "length = %d\n", l);
3886 IHTMLStyleSheetsCollection_Release(stylesheetcol);
3888 test_default_selection(doc);
3889 test_doc_title(doc, "");
3892 static void test_tr_elem(IHTMLElement *elem)
3894 IHTMLElementCollection *col;
3895 IHTMLTableRow *row;
3896 HRESULT hres;
3898 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
3900 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
3901 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
3902 if(FAILED(hres))
3903 return;
3905 col = NULL;
3906 hres = IHTMLTableRow_get_cells(row, &col);
3907 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
3908 ok(col != NULL, "get_cells returned NULL\n");
3910 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
3911 IHTMLElementCollection_Release(col);
3913 IHTMLTable_Release(row);
3916 static void test_table_elem(IHTMLElement *elem)
3918 IHTMLElementCollection *col;
3919 IHTMLTable *table;
3920 HRESULT hres;
3922 static const elem_type_t row_types[] = {ET_TR,ET_TR};
3924 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
3925 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
3926 if(FAILED(hres))
3927 return;
3929 col = NULL;
3930 hres = IHTMLTable_get_rows(table, &col);
3931 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
3932 ok(col != NULL, "get_ros returned NULL\n");
3934 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
3935 IHTMLElementCollection_Release(col);
3937 IHTMLTable_Release(table);
3940 static void doc_write(IHTMLDocument2 *doc, const char *text)
3942 SAFEARRAYBOUND dim;
3943 SAFEARRAY *sa;
3944 VARIANT *var;
3945 BSTR str;
3946 HRESULT hres;
3948 dim.lLbound = 0;
3949 dim.cElements = 1;
3950 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
3951 SafeArrayAccessData(sa, (void**)&var);
3952 V_VT(var) = VT_BSTR;
3953 V_BSTR(var) = str = a2bstr(text);
3954 SafeArrayUnaccessData(sa);
3956 hres = IHTMLDocument2_write(doc, sa);
3957 ok(hres == S_OK, "write failed: %08x\n", hres);
3959 SysFreeString(str);
3960 SafeArrayDestroy(sa);
3963 static void test_iframe_elem(IHTMLElement *elem)
3965 IHTMLElementCollection *col;
3966 IHTMLDocument2 *content_doc;
3967 IHTMLWindow2 *content_window;
3968 IHTMLFrameBase2 *base2;
3969 IDispatch *disp;
3970 VARIANT errv;
3971 BSTR str;
3972 HRESULT hres;
3974 static const elem_type_t all_types[] = {
3975 ET_HTML,
3976 ET_HEAD,
3977 ET_TITLE,
3978 ET_BODY,
3979 ET_BR
3982 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
3983 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
3984 if (!base2) return;
3986 content_window = NULL;
3987 hres = IHTMLFrameBase2_get_contentWindow(base2, &content_window);
3988 IHTMLFrameBase2_Release(base2);
3989 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
3990 ok(content_window != NULL, "contentWindow = NULL\n");
3992 content_doc = NULL;
3993 hres = IHTMLWindow2_get_document(content_window, &content_doc);
3994 IHTMLWindow2_Release(content_window);
3995 ok(hres == S_OK, "get_document failed: %08x\n", hres);
3996 ok(content_doc != NULL, "content_doc = NULL\n");
3998 str = a2bstr("text/html");
3999 V_VT(&errv) = VT_ERROR;
4000 disp = NULL;
4001 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4002 SysFreeString(str);
4003 ok(hres == S_OK, "open failed: %08x\n", hres);
4004 ok(disp != NULL, "disp == NULL\n");
4005 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4006 IDispatch_Release(disp);
4008 doc_write(content_doc, "<html><head><title>test</title></head><body><br /></body></html>");
4010 hres = IHTMLDocument2_get_all(content_doc, &col);
4011 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4012 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4013 IHTMLElementCollection_Release(col);
4015 hres = IHTMLDocument2_close(content_doc);
4016 ok(hres == S_OK, "close failed: %08x\n", hres);
4018 IHTMLDocument2_Release(content_doc);
4021 static void test_stylesheet(IDispatch *disp)
4023 IHTMLStyleSheetRulesCollection *col = NULL;
4024 IHTMLStyleSheet *stylesheet;
4025 HRESULT hres;
4027 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4028 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4030 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4031 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4032 ok(col != NULL, "col == NULL\n");
4034 IHTMLStyleSheetRulesCollection_Release(col);
4035 IHTMLStyleSheet_Release(stylesheet);
4038 static void test_stylesheets(IHTMLDocument2 *doc)
4040 IHTMLStyleSheetsCollection *col = NULL;
4041 VARIANT idx, res;
4042 LONG len = 0;
4043 HRESULT hres;
4045 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4046 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4047 ok(col != NULL, "col == NULL\n");
4049 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4050 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4051 ok(len == 1, "len=%d\n", len);
4053 VariantInit(&res);
4054 V_VT(&idx) = VT_I4;
4055 V_I4(&idx) = 0;
4057 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4058 ok(hres == S_OK, "item failed: %08x\n", hres);
4059 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4060 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4061 test_stylesheet(V_DISPATCH(&res));
4062 VariantClear(&res);
4064 V_VT(&res) = VT_I4;
4065 V_VT(&idx) = VT_I4;
4066 V_I4(&idx) = 1;
4068 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4069 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4070 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4071 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4072 VariantClear(&res);
4074 IHTMLStyleSheetsCollection_Release(col);
4077 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4079 IDispatchEx *dispex;
4080 IHTMLDOMNode *node;
4081 DISPPARAMS dp = {NULL, NULL, 0, 0};
4082 VARIANT var;
4083 EXCEPINFO ei;
4084 LONG type;
4085 DISPID id;
4086 BSTR bstr;
4087 HRESULT hres;
4089 static const WCHAR w0[] = {'0',0};
4090 static const WCHAR w100[] = {'1','0','0',0};
4092 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4093 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4095 bstr = SysAllocString(w0);
4096 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4097 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4098 SysFreeString(bstr);
4100 VariantInit(&var);
4101 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4102 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4103 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4104 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4105 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4106 type = get_node_type((IUnknown*)node);
4107 ok(type == 3, "type=%d\n", type);
4108 IHTMLDOMNode_Release(node);
4109 VariantClear(&var);
4111 bstr = SysAllocString(w100);
4112 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4113 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4114 SysFreeString(bstr);
4116 IDispatchEx_Release(dispex);
4121 static void test_elems(IHTMLDocument2 *doc)
4123 IHTMLElementCollection *col;
4124 IHTMLDOMChildrenCollection *child_col;
4125 IHTMLElement *elem, *elem2, *elem3;
4126 IHTMLDOMNode *node, *node2;
4127 IDispatch *disp;
4128 LONG type;
4129 HRESULT hres;
4130 IHTMLElementCollection *collection;
4131 IHTMLDocument3 *doc3;
4132 BSTR str;
4134 static const elem_type_t all_types[] = {
4135 ET_HTML,
4136 ET_HEAD,
4137 ET_TITLE,
4138 ET_STYLE,
4139 ET_BODY,
4140 ET_COMMENT,
4141 ET_A,
4142 ET_INPUT,
4143 ET_SELECT,
4144 ET_OPTION,
4145 ET_OPTION,
4146 ET_TEXTAREA,
4147 ET_TABLE,
4148 ET_TBODY,
4149 ET_TR,
4150 ET_TR,
4151 ET_TD,
4152 ET_TD,
4153 ET_SCRIPT,
4154 ET_TEST,
4155 ET_IMG,
4156 ET_IFRAME
4159 static const elem_type_t item_types[] = {
4160 ET_A,
4161 ET_OPTION,
4162 ET_TEXTAREA
4165 hres = IHTMLDocument2_get_all(doc, &col);
4166 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4167 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4168 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
4169 IHTMLElementCollection_Release(col);
4171 hres = IHTMLDocument2_get_images(doc, &collection);
4172 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4173 if(hres == S_OK)
4175 static const elem_type_t images_types[] = {ET_IMG};
4176 test_elem_collection((IUnknown*)collection, images_types, 1);
4178 IHTMLElementCollection_Release(collection);
4181 hres = IHTMLDocument2_get_links(doc, &collection);
4182 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4183 if(hres == S_OK)
4185 static const elem_type_t images_types[] = {ET_A};
4186 test_elem_collection((IUnknown*)collection, images_types, 1);
4188 IHTMLElementCollection_Release(collection);
4191 hres = IHTMLDocument2_get_anchors(doc, &collection);
4192 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4193 if(hres == S_OK)
4195 static const elem_type_t anchor_types[] = {ET_A};
4196 test_elem_collection((IUnknown*)collection, anchor_types, 1);
4198 IHTMLElementCollection_Release(collection);
4201 elem = get_doc_elem(doc);
4202 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4203 hres = IHTMLElement_get_all(elem, &disp);
4204 IHTMLElement_Release(elem);
4205 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4207 hres = IDispatch_QueryInterface(disp, &IID_IHTMLElementCollection, (void**)&col);
4208 IDispatch_Release(disp);
4209 ok(hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
4210 test_elem_collection((IUnknown*)col, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
4211 IHTMLElementCollection_Release(col);
4213 get_elem_by_id(doc, "xxx", FALSE);
4214 elem = get_doc_elem_by_id(doc, "xxx");
4215 ok(!elem, "elem != NULL\n");
4217 elem = get_doc_elem_by_id(doc, "s");
4218 ok(elem != NULL, "elem == NULL\n");
4219 if(elem) {
4220 test_elem_type((IUnknown*)elem, ET_SELECT);
4221 test_elem_attr(elem, "xxx", NULL);
4222 test_elem_attr(elem, "id", "s");
4223 test_elem_class((IUnknown*)elem, NULL);
4224 test_elem_set_class((IUnknown*)elem, "cl");
4225 test_elem_set_class((IUnknown*)elem, NULL);
4226 test_elem_tabindex((IUnknown*)elem, 0);
4227 test_elem_set_tabindex((IUnknown*)elem, 1);
4229 node = test_node_get_parent((IUnknown*)elem);
4230 ok(node != NULL, "node == NULL\n");
4231 test_node_name((IUnknown*)node, "BODY");
4232 node2 = test_node_get_parent((IUnknown*)node);
4233 IHTMLDOMNode_Release(node);
4234 ok(node2 != NULL, "node == NULL\n");
4235 test_node_name((IUnknown*)node2, "HTML");
4236 node = test_node_get_parent((IUnknown*)node2);
4237 IHTMLDOMNode_Release(node2);
4238 ok(node != NULL, "node == NULL\n");
4239 if (node)
4241 test_node_name((IUnknown*)node, "#document");
4242 type = get_node_type((IUnknown*)node);
4243 ok(type == 9, "type=%d, expected 9\n", type);
4244 node2 = test_node_get_parent((IUnknown*)node);
4245 IHTMLDOMNode_Release(node);
4246 ok(node2 == NULL, "node != NULL\n");
4249 elem2 = test_elem_get_parent((IUnknown*)elem);
4250 ok(elem2 != NULL, "elem2 == NULL\n");
4251 test_node_name((IUnknown*)elem2, "BODY");
4252 elem3 = test_elem_get_parent((IUnknown*)elem2);
4253 IHTMLElement_Release(elem2);
4254 ok(elem3 != NULL, "elem3 == NULL\n");
4255 test_node_name((IUnknown*)elem3, "HTML");
4256 elem2 = test_elem_get_parent((IUnknown*)elem3);
4257 IHTMLElement_Release(elem3);
4258 ok(elem2 == NULL, "elem2 != NULL\n");
4260 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
4261 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
4262 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
4264 test_elem_innertext(elem, "opt1opt2");
4266 IHTMLElement_Release(elem);
4269 elem = get_elem_by_id(doc, "s", TRUE);
4270 if(elem) {
4271 IHTMLSelectElement *select;
4273 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
4274 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
4276 test_select_elem(select);
4278 test_elem_title((IUnknown*)select, NULL);
4279 test_elem_set_title((IUnknown*)select, "Title");
4280 test_elem_title((IUnknown*)select, "Title");
4281 test_elem_offset((IUnknown*)select);
4283 node = get_first_child((IUnknown*)select);
4284 ok(node != NULL, "node == NULL\n");
4285 if(node) {
4286 test_elem_type((IUnknown*)node, ET_OPTION);
4287 IHTMLDOMNode_Release(node);
4290 type = get_node_type((IUnknown*)select);
4291 ok(type == 1, "type=%d\n", type);
4293 IHTMLSelectElement_Release(select);
4295 hres = IHTMLElement_get_document(elem, &disp);
4296 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4297 ok(iface_cmp((IUnknown*)disp, (IUnknown*)doc), "disp != doc\n");
4299 IHTMLElement_Release(elem);
4302 elem = get_elem_by_id(doc, "sc", TRUE);
4303 if(elem) {
4304 IHTMLScriptElement *script;
4305 BSTR type;
4307 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
4308 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
4310 if(hres == S_OK)
4312 VARIANT_BOOL vb;
4314 hres = IHTMLScriptElement_get_type(script, &type);
4315 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4316 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", dbgstr_w(type));
4317 SysFreeString(type);
4319 /* test defer */
4320 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
4321 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4323 hres = IHTMLScriptElement_get_defer(script, &vb);
4324 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
4325 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
4327 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
4328 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4331 IHTMLScriptElement_Release(script);
4334 elem = get_elem_by_id(doc, "in", TRUE);
4335 if(elem) {
4336 IHTMLInputElement *input;
4338 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
4339 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
4341 test_elem_id((IUnknown*)elem, "in");
4342 test_elem_put_id((IUnknown*)elem, "newin");
4343 test_input_get_disabled(input, VARIANT_FALSE);
4344 test_input_set_disabled(input, VARIANT_TRUE);
4345 test_input_set_disabled(input, VARIANT_FALSE);
4346 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
4347 test_input_get_disabled(input, VARIANT_TRUE);
4348 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
4349 test_input_get_disabled(input, VARIANT_FALSE);
4350 test_elem_client_size((IUnknown*)elem);
4352 test_node_get_value_str((IUnknown*)elem, NULL);
4353 test_node_put_value_str((IUnknown*)elem, "test");
4354 test_node_get_value_str((IUnknown*)elem, NULL);
4355 test_input_value((IUnknown*)elem, NULL);
4356 test_input_put_value((IUnknown*)elem, "test");
4357 test_input_value((IUnknown*)elem, NULL);
4358 test_elem_class((IUnknown*)elem, "testclass");
4359 test_elem_tabindex((IUnknown*)elem, 2);
4360 test_elem_set_tabindex((IUnknown*)elem, 3);
4361 test_elem_title((IUnknown*)elem, "test title");
4363 test_input_get_defaultchecked(input, VARIANT_FALSE);
4364 test_input_set_defaultchecked(input, VARIANT_TRUE);
4365 test_input_set_defaultchecked(input, VARIANT_FALSE);
4367 test_input_get_checked(input, VARIANT_FALSE);
4368 test_input_set_checked(input, VARIANT_TRUE);
4369 test_input_set_checked(input, VARIANT_FALSE);
4371 IHTMLInputElement_Release(input);
4372 IHTMLElement_Release(elem);
4375 elem = get_elem_by_id(doc, "imgid", TRUE);
4376 if(elem) {
4377 test_img_src((IUnknown*)elem, "");
4378 test_img_set_src((IUnknown*)elem, "about:blank");
4379 test_img_alt((IUnknown*)elem, NULL);
4380 test_img_set_alt((IUnknown*)elem, "alt test");
4381 IHTMLElement_Release(elem);
4384 elem = get_doc_elem_by_id(doc, "tbl");
4385 ok(elem != NULL, "elem == NULL\n");
4386 if(elem) {
4387 test_table_elem(elem);
4388 IHTMLElement_Release(elem);
4391 elem = get_doc_elem_by_id(doc, "row2");
4392 ok(elem != NULL, "elem == NULL\n");
4393 if(elem) {
4394 test_tr_elem(elem);
4395 IHTMLElement_Release(elem);
4398 elem = get_doc_elem_by_id(doc, "ifr");
4399 ok(elem != NULL, "elem == NULL\n");
4400 if(elem) {
4401 test_iframe_elem(elem);
4402 IHTMLElement_Release(elem);
4405 hres = IHTMLDocument2_get_body(doc, &elem);
4406 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4408 node = get_first_child((IUnknown*)elem);
4409 ok(node != NULL, "node == NULL\n");
4410 if(node) {
4411 test_ifaces((IUnknown*)node, text_iids);
4412 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode);
4414 node2 = get_first_child((IUnknown*)node);
4415 ok(!node2, "node2 != NULL\n");
4417 type = get_node_type((IUnknown*)node);
4418 ok(type == 3, "type=%d\n", type);
4420 test_node_get_value_str((IUnknown*)node, "text test");
4421 test_node_put_value_str((IUnknown*)elem, "test text");
4422 test_node_get_value_str((IUnknown*)node, "text test");
4424 IHTMLDOMNode_Release(node);
4427 child_col = get_child_nodes((IUnknown*)elem);
4428 ok(child_col != NULL, "child_coll == NULL\n");
4429 if(child_col) {
4430 LONG length = 0;
4432 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection);
4434 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
4435 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4436 ok(length, "length=0\n");
4438 node = get_child_item(child_col, 0);
4439 ok(node != NULL, "node == NULL\n");
4440 if(node) {
4441 type = get_node_type((IUnknown*)node);
4442 ok(type == 3, "type=%d\n", type);
4443 IHTMLDOMNode_Release(node);
4446 node = get_child_item(child_col, 1);
4447 ok(node != NULL, "node == NULL\n");
4448 if(node) {
4449 type = get_node_type((IUnknown*)node);
4450 ok(type == 8, "type=%d\n", type);
4452 test_elem_id((IUnknown*)node, NULL);
4453 IHTMLDOMNode_Release(node);
4456 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
4457 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
4459 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
4460 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
4462 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
4463 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4465 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
4466 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4468 test_child_col_disp(child_col);
4470 IHTMLDOMChildrenCollection_Release(child_col);
4473 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
4474 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
4475 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
4477 IHTMLElement_Release(elem);
4479 test_stylesheets(doc);
4480 test_create_option_elem(doc);
4482 elem = get_doc_elem_by_id(doc, "tbl");
4483 ok(elem != NULL, "elem = NULL\n");
4484 test_elem_set_innertext(elem, "inner text");
4485 IHTMLElement_Release(elem);
4487 test_doc_title(doc, "test");
4488 test_doc_set_title(doc, "test title");
4489 test_doc_title(doc, "test title");
4491 disp = NULL;
4492 hres = IHTMLDocument2_get_Script(doc, &disp);
4493 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4494 if(hres == S_OK)
4496 IDispatchEx *dispex;
4497 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
4498 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
4499 if(hres == S_OK)
4501 DISPID pid = -1;
4502 BSTR str = a2bstr("Testing");
4503 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
4504 todo_wine ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4505 todo_wine ok(pid != -1, "pid == -1\n");
4506 SysFreeString(str);
4507 IDispatchEx_Release(dispex);
4510 IDispatch_Release(disp);
4512 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4513 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
4515 str = a2bstr("img");
4516 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
4517 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", dbgstr_w(str), hres);
4518 SysFreeString(str);
4519 if(hres == S_OK)
4521 static const elem_type_t img_types[] = { ET_IMG };
4523 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
4524 IHTMLElementCollection_Release(col);
4527 elem = get_doc_elem_by_id(doc, "y");
4528 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
4529 test_elem_innerhtml((IUnknown*)elem, "inner html");
4530 test_elem_set_innerhtml((IUnknown*)elem, "");
4531 test_elem_innerhtml((IUnknown*)elem, NULL);
4532 IHTMLElement_Release(elem);
4534 IHTMLDocument3_Release(doc3);
4537 static void test_create_elems(IHTMLDocument2 *doc)
4539 IHTMLElement *elem, *body, *elem2;
4540 IHTMLDOMNode *node, *node2, *node3, *comment;
4541 IHTMLDocument5 *doc5;
4542 IDispatch *disp;
4543 VARIANT var;
4544 LONG type;
4545 HRESULT hres;
4546 BSTR str;
4548 static const elem_type_t types1[] = { ET_TESTG };
4550 elem = test_create_elem(doc, "TEST");
4551 test_elem_tag((IUnknown*)elem, "TEST");
4552 type = get_node_type((IUnknown*)elem);
4553 ok(type == 1, "type=%d\n", type);
4554 test_ifaces((IUnknown*)elem, elem_iids);
4555 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement);
4557 hres = IHTMLDocument2_get_body(doc, &body);
4558 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4559 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
4561 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
4562 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
4563 elem2 = get_elem_iface((IUnknown*)node);
4564 IHTMLElement_Release(elem2);
4566 hres = IHTMLElement_get_all(body, &disp);
4567 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4568 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
4569 IDispatch_Release(disp);
4571 test_node_remove_child((IUnknown*)body, node);
4573 hres = IHTMLElement_get_all(body, &disp);
4574 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4575 test_elem_collection((IUnknown*)disp, NULL, 0);
4576 IDispatch_Release(disp);
4577 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
4579 IHTMLElement_Release(elem);
4580 IHTMLDOMNode_Release(node);
4582 node = test_create_text(doc, "test");
4583 test_ifaces((IUnknown*)node, text_iids);
4584 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode);
4586 V_VT(&var) = VT_NULL;
4587 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
4588 IHTMLDOMNode_Release(node);
4590 node = test_create_text(doc, "insert ");
4592 V_VT(&var) = VT_DISPATCH;
4593 V_DISPATCH(&var) = (IDispatch*)node2;
4594 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
4595 IHTMLDOMNode_Release(node);
4596 IHTMLDOMNode_Release(node2);
4597 IHTMLDOMNode_Release(node3);
4599 test_elem_innertext(body, "insert test");
4600 test_elem_innerhtml((IUnknown*)body, "insert test");
4602 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
4603 if(hres == S_OK)
4605 str = a2bstr("testing");
4606 hres = IHTMLDocument5_createComment(doc5, str, &comment);
4607 SysFreeString(str);
4608 ok(hres == S_OK, "createComment failed: %08x\n", hres);
4609 if(hres == S_OK)
4611 type = get_node_type((IUnknown*)comment);
4612 ok(type == 8, "type=%d, expected 8\n", type);
4614 test_node_get_value_str((IUnknown*)comment, "testing");
4616 IHTMLDOMNode_Release(comment);
4619 IHTMLDocument5_Release(doc5);
4622 IHTMLElement_Release(body);
4625 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
4627 IOleCommandTarget *cmdtrg;
4628 HRESULT hres;
4630 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
4631 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
4633 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
4634 ok(hres == S_OK, "Exec failed: %08x\n", hres);
4636 IOleCommandTarget_Release(cmdtrg);
4639 static void test_indent(IHTMLDocument2 *doc)
4641 IHTMLElementCollection *col;
4642 IHTMLTxtRange *range;
4643 HRESULT hres;
4645 static const elem_type_t all_types[] = {
4646 ET_HTML,
4647 ET_HEAD,
4648 ET_TITLE,
4649 ET_BODY,
4650 ET_BR,
4651 ET_A,
4654 static const elem_type_t indent_types[] = {
4655 ET_HTML,
4656 ET_HEAD,
4657 ET_TITLE,
4658 ET_BODY,
4659 ET_BLOCKQUOTE,
4660 ET_P,
4661 ET_BR,
4662 ET_A,
4665 hres = IHTMLDocument2_get_all(doc, &col);
4666 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4667 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4668 IHTMLElementCollection_Release(col);
4670 range = test_create_body_range(doc);
4671 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
4672 IHTMLTxtRange_Release(range);
4674 hres = IHTMLDocument2_get_all(doc, &col);
4675 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4676 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
4677 IHTMLElementCollection_Release(col);
4680 static void test_cond_comment(IHTMLDocument2 *doc)
4682 IHTMLElementCollection *col;
4683 HRESULT hres;
4685 static const elem_type_t all_types[] = {
4686 ET_HTML,
4687 ET_HEAD,
4688 ET_TITLE,
4689 ET_BODY,
4690 ET_BR
4693 hres = IHTMLDocument2_get_all(doc, &col);
4694 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4695 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4696 IHTMLElementCollection_Release(col);
4699 static IHTMLDocument2 *notif_doc;
4700 static BOOL doc_complete;
4702 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
4703 REFIID riid, void**ppv)
4705 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
4706 *ppv = iface;
4707 return S_OK;
4710 ok(0, "unexpected call\n");
4711 return E_NOINTERFACE;
4714 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
4716 return 2;
4719 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
4721 return 1;
4724 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
4726 if(dispID == DISPID_READYSTATE){
4727 BSTR state;
4728 HRESULT hres;
4730 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
4731 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
4733 if(!strcmp_wa(state, "complete"))
4734 doc_complete = TRUE;
4736 SysFreeString(state);
4739 return S_OK;
4742 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
4744 ok(0, "unexpected call\n");
4745 return E_NOTIMPL;
4748 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
4749 PropertyNotifySink_QueryInterface,
4750 PropertyNotifySink_AddRef,
4751 PropertyNotifySink_Release,
4752 PropertyNotifySink_OnChanged,
4753 PropertyNotifySink_OnRequestEdit
4756 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
4758 static IHTMLDocument2 *create_doc_with_string(const char *str)
4760 IPersistStreamInit *init;
4761 IStream *stream;
4762 IHTMLDocument2 *doc;
4763 HGLOBAL mem;
4764 SIZE_T len;
4766 notif_doc = doc = create_document();
4767 if(!doc)
4768 return NULL;
4770 doc_complete = FALSE;
4771 len = strlen(str);
4772 mem = GlobalAlloc(0, len);
4773 memcpy(mem, str, len);
4774 CreateStreamOnHGlobal(mem, TRUE, &stream);
4776 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
4778 IPersistStreamInit_Load(init, stream);
4779 IPersistStreamInit_Release(init);
4780 IStream_Release(stream);
4782 return doc;
4785 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
4787 IConnectionPointContainer *container;
4788 IConnectionPoint *cp;
4789 DWORD cookie;
4790 HRESULT hres;
4792 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
4793 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
4795 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
4796 IConnectionPointContainer_Release(container);
4797 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
4799 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
4800 IConnectionPoint_Release(cp);
4801 ok(hres == S_OK, "Advise failed: %08x\n", hres);
4804 typedef void (*domtest_t)(IHTMLDocument2*);
4806 static void run_domtest(const char *str, domtest_t test)
4808 IHTMLDocument2 *doc;
4809 IHTMLElement *body = NULL;
4810 ULONG ref;
4811 MSG msg;
4812 HRESULT hres;
4814 doc = create_doc_with_string(str);
4815 if(!doc)
4816 return;
4818 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
4820 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
4821 TranslateMessage(&msg);
4822 DispatchMessage(&msg);
4825 hres = IHTMLDocument2_get_body(doc, &body);
4826 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4828 if(body) {
4829 IHTMLElement_Release(body);
4830 test(doc);
4831 }else {
4832 skip("Could not get document body. Assuming no Gecko installed.\n");
4835 ref = IHTMLDocument2_Release(doc);
4836 ok(!ref ||
4837 ref == 1, /* Vista */
4838 "ref = %d\n", ref);
4841 static void gecko_installer_workaround(BOOL disable)
4843 HKEY hkey;
4844 DWORD res;
4846 static BOOL has_url = FALSE;
4847 static char url[2048];
4849 if(!disable && !has_url)
4850 return;
4852 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
4853 if(res != ERROR_SUCCESS)
4854 return;
4856 if(disable) {
4857 DWORD type, size = sizeof(url);
4859 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
4860 if(res == ERROR_SUCCESS && type == REG_SZ)
4861 has_url = TRUE;
4863 RegDeleteValue(hkey, "GeckoUrl");
4864 }else {
4865 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
4868 RegCloseKey(hkey);
4871 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
4872 /* Note: this code is duplicated in dlls/mshtml/tests/dom.c, dlls/mshtml/tests/script.c and dlls/urlmon/tests/sec_mgr.c */
4873 static BOOL is_ie_hardened(void)
4875 HKEY zone_map;
4876 DWORD ie_harden, type, size;
4878 ie_harden = 0;
4879 if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
4880 0, KEY_QUERY_VALUE, &zone_map) == ERROR_SUCCESS) {
4881 size = sizeof(DWORD);
4882 if (RegQueryValueEx(zone_map, "IEHarden", NULL, &type, (LPBYTE) &ie_harden, &size) != ERROR_SUCCESS ||
4883 type != REG_DWORD) {
4884 ie_harden = 0;
4886 RegCloseKey(zone_map);
4889 return ie_harden != 0;
4892 START_TEST(dom)
4894 gecko_installer_workaround(TRUE);
4895 CoInitialize(NULL);
4897 run_domtest(doc_str1, test_doc_elem);
4898 run_domtest(range_test_str, test_txtrange);
4899 run_domtest(range_test2_str, test_txtrange2);
4900 if (winetest_interactive || ! is_ie_hardened()) {
4901 run_domtest(elem_test_str, test_elems);
4902 }else {
4903 skip("IE running in Enhanced Security Configuration\n");
4905 run_domtest(doc_blank, test_create_elems);
4906 run_domtest(doc_blank, test_defaults);
4907 run_domtest(indent_test_str, test_indent);
4908 run_domtest(cond_comment_str, test_cond_comment);
4910 CoUninitialize();
4911 gecko_installer_workaround(FALSE);