mshtml: Added IHTMLTextAreaElement::put_value implementation.
[wine/hacks.git] / dlls / mshtml / tests / dom.c
bloba66b13cd2c2d208a9ed2c3347c39b15894a922ac
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"
34 #include "mshtml_test.h"
36 static const char doc_blank[] = "<html></html>";
37 static const char doc_str1[] = "<html><body>test</body></html>";
38 static const char range_test_str[] =
39 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
40 static const char range_test2_str[] =
41 "<html><body>abc<hr />123<br /><hr />def</body></html>";
42 static const char elem_test_str[] =
43 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
44 "<body onload=\"Testing()\">text test<!-- a comment -->"
45 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
46 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
47 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
48 "<textarea id=\"X\">text text</textarea>"
49 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
50 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
51 "<test />"
52 "<img id=\"imgid\" name=\"WineImg\"/>"
53 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
54 "<form id=\"frm\"></form>"
55 "</body></html>";
56 static const char elem_test2_str[] =
57 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
58 "<body><div id=\"divid\"></div></body>"
59 "</html>";
61 static const char indent_test_str[] =
62 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
63 static const char cond_comment_str[] =
64 "<html><head><title>test</title></head><body>"
65 "<!--[if gte IE 4]> <br> <![endif]-->"
66 "</body></html>";
67 static const char frameset_str[] =
68 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
69 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
70 "<frame src=\"about:blank\" id=\"fr3\">"
71 "</frameset></html>";
73 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
74 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
75 static WCHAR wordW[] = {'w','o','r','d',0};
77 typedef enum {
78 ET_NONE,
79 ET_HTML,
80 ET_HEAD,
81 ET_TITLE,
82 ET_BODY,
83 ET_A,
84 ET_INPUT,
85 ET_SELECT,
86 ET_TEXTAREA,
87 ET_OPTION,
88 ET_STYLE,
89 ET_BLOCKQUOTE,
90 ET_P,
91 ET_BR,
92 ET_TABLE,
93 ET_TBODY,
94 ET_SCRIPT,
95 ET_TEST,
96 ET_TESTG,
97 ET_COMMENT,
98 ET_IMG,
99 ET_TR,
100 ET_TD,
101 ET_IFRAME,
102 ET_FORM,
103 ET_FRAME
104 } elem_type_t;
106 static const IID * const none_iids[] = {
107 &IID_IUnknown,
108 NULL
111 static const IID * const doc_node_iids[] = {
112 &IID_IHTMLDOMNode,
113 &IID_IHTMLDOMNode2,
114 &IID_IHTMLDocument,
115 &IID_IHTMLDocument2,
116 &IID_IHTMLDocument3,
117 &IID_IHTMLDocument4,
118 &IID_IHTMLDocument5,
119 &IID_IDispatchEx,
120 &IID_IConnectionPointContainer,
121 &IID_IInternetHostSecurityManager,
122 NULL
125 static const IID * const doc_obj_iids[] = {
126 &IID_IHTMLDocument,
127 &IID_IHTMLDocument2,
128 &IID_IHTMLDocument3,
129 &IID_IHTMLDocument4,
130 &IID_IHTMLDocument5,
131 &IID_IDispatchEx,
132 &IID_IConnectionPointContainer,
133 &IID_ICustomDoc,
134 NULL
137 static const IID * const elem_iids[] = {
138 &IID_IHTMLDOMNode,
139 &IID_IHTMLDOMNode2,
140 &IID_IHTMLElement,
141 &IID_IHTMLElement2,
142 &IID_IHTMLElement3,
143 &IID_IDispatchEx,
144 &IID_IConnectionPointContainer,
145 NULL
148 static const IID * const body_iids[] = {
149 &IID_IHTMLDOMNode,
150 &IID_IHTMLDOMNode2,
151 &IID_IHTMLElement,
152 &IID_IHTMLElement2,
153 &IID_IHTMLElement3,
154 &IID_IHTMLTextContainer,
155 &IID_IHTMLBodyElement,
156 &IID_IDispatchEx,
157 &IID_IConnectionPointContainer,
158 NULL
161 static const IID * const anchor_iids[] = {
162 &IID_IHTMLDOMNode,
163 &IID_IHTMLDOMNode2,
164 &IID_IHTMLElement,
165 &IID_IHTMLElement2,
166 &IID_IHTMLElement3,
167 &IID_IHTMLAnchorElement,
168 &IID_IDispatchEx,
169 &IID_IConnectionPointContainer,
170 NULL
173 static const IID * const input_iids[] = {
174 &IID_IHTMLDOMNode,
175 &IID_IHTMLDOMNode2,
176 &IID_IHTMLElement,
177 &IID_IHTMLElement2,
178 &IID_IHTMLElement3,
179 &IID_IHTMLInputElement,
180 &IID_IHTMLInputTextElement,
181 &IID_IDispatchEx,
182 &IID_IConnectionPointContainer,
183 NULL
186 static const IID * const select_iids[] = {
187 &IID_IHTMLDOMNode,
188 &IID_IHTMLDOMNode2,
189 &IID_IHTMLElement,
190 &IID_IHTMLElement2,
191 &IID_IHTMLElement3,
192 &IID_IHTMLSelectElement,
193 &IID_IDispatchEx,
194 &IID_IConnectionPointContainer,
195 NULL
198 static const IID * const textarea_iids[] = {
199 &IID_IHTMLDOMNode,
200 &IID_IHTMLDOMNode2,
201 &IID_IHTMLElement,
202 &IID_IHTMLElement2,
203 &IID_IHTMLElement3,
204 &IID_IHTMLTextAreaElement,
205 &IID_IDispatchEx,
206 &IID_IConnectionPointContainer,
207 NULL
210 static const IID * const option_iids[] = {
211 &IID_IHTMLDOMNode,
212 &IID_IHTMLDOMNode2,
213 &IID_IHTMLElement,
214 &IID_IHTMLElement2,
215 &IID_IHTMLElement3,
216 &IID_IHTMLOptionElement,
217 &IID_IDispatchEx,
218 &IID_IConnectionPointContainer,
219 NULL
222 static const IID * const table_iids[] = {
223 &IID_IHTMLDOMNode,
224 &IID_IHTMLDOMNode2,
225 &IID_IHTMLElement,
226 &IID_IHTMLElement2,
227 &IID_IHTMLElement3,
228 &IID_IHTMLTable,
229 &IID_IDispatchEx,
230 &IID_IConnectionPointContainer,
231 NULL
234 static const IID * const script_iids[] = {
235 &IID_IHTMLDOMNode,
236 &IID_IHTMLDOMNode2,
237 &IID_IHTMLElement,
238 &IID_IHTMLElement2,
239 &IID_IHTMLElement3,
240 &IID_IHTMLScriptElement,
241 &IID_IDispatchEx,
242 &IID_IConnectionPointContainer,
243 NULL
246 static const IID * const text_iids[] = {
247 &IID_IHTMLDOMNode,
248 &IID_IHTMLDOMNode2,
249 &IID_IHTMLDOMTextNode,
250 NULL
253 static const IID * const location_iids[] = {
254 &IID_IDispatch,
255 &IID_IHTMLLocation,
256 NULL
259 static const IID * const window_iids[] = {
260 &IID_IDispatch,
261 &IID_IHTMLWindow2,
262 &IID_IHTMLWindow3,
263 &IID_IDispatchEx,
264 NULL
267 static const IID * const comment_iids[] = {
268 &IID_IHTMLDOMNode,
269 &IID_IHTMLDOMNode2,
270 &IID_IHTMLElement,
271 &IID_IHTMLElement2,
272 &IID_IHTMLElement3,
273 &IID_IHTMLCommentElement,
274 &IID_IDispatchEx,
275 &IID_IConnectionPointContainer,
276 NULL
279 static const IID * const img_iids[] = {
280 &IID_IHTMLDOMNode,
281 &IID_IHTMLDOMNode2,
282 &IID_IHTMLElement,
283 &IID_IHTMLElement2,
284 &IID_IHTMLElement3,
285 &IID_IDispatchEx,
286 &IID_IHTMLImgElement,
287 &IID_IConnectionPointContainer,
288 NULL
291 static const IID * const tr_iids[] = {
292 &IID_IHTMLDOMNode,
293 &IID_IHTMLDOMNode2,
294 &IID_IHTMLElement,
295 &IID_IHTMLElement2,
296 &IID_IHTMLElement3,
297 &IID_IDispatchEx,
298 &IID_IHTMLTableRow,
299 &IID_IConnectionPointContainer,
300 NULL
303 static const IID * const td_iids[] = {
304 &IID_IHTMLDOMNode,
305 &IID_IHTMLDOMNode2,
306 &IID_IHTMLElement,
307 &IID_IHTMLElement2,
308 &IID_IHTMLElement3,
309 &IID_IDispatchEx,
310 &IID_IConnectionPointContainer,
311 NULL
314 static const IID * const frame_iids[] = {
315 &IID_IHTMLDOMNode,
316 &IID_IHTMLDOMNode2,
317 &IID_IHTMLElement,
318 &IID_IHTMLElement2,
319 &IID_IHTMLElement3,
320 &IID_IHTMLFrameBase,
321 &IID_IHTMLFrameBase2,
322 &IID_IDispatchEx,
323 &IID_IConnectionPointContainer,
324 NULL
327 static const IID * const iframe_iids[] = {
328 &IID_IHTMLDOMNode,
329 &IID_IHTMLDOMNode2,
330 &IID_IHTMLElement,
331 &IID_IHTMLElement2,
332 &IID_IHTMLElement3,
333 &IID_IHTMLFrameBase,
334 &IID_IHTMLFrameBase2,
335 &IID_IHTMLIFrameElement,
336 &IID_IDispatchEx,
337 &IID_IConnectionPointContainer,
338 NULL
341 static const IID * const form_iids[] = {
342 &IID_IHTMLDOMNode,
343 &IID_IHTMLDOMNode2,
344 &IID_IHTMLElement,
345 &IID_IHTMLElement2,
346 &IID_IHTMLElement3,
347 &IID_IHTMLFormElement,
348 &IID_IDispatchEx,
349 &IID_IConnectionPointContainer,
350 NULL
353 static const IID * const generic_iids[] = {
354 &IID_IHTMLDOMNode,
355 &IID_IHTMLDOMNode2,
356 &IID_IHTMLElement,
357 &IID_IHTMLElement2,
358 &IID_IHTMLElement3,
359 &IID_IHTMLGenericElement,
360 &IID_IDispatchEx,
361 &IID_IConnectionPointContainer,
362 NULL
365 static const IID * const style_iids[] = {
366 &IID_IUnknown,
367 &IID_IDispatch,
368 &IID_IDispatchEx,
369 &IID_IHTMLStyle,
370 &IID_IHTMLStyle2,
371 &IID_IHTMLStyle3,
372 &IID_IHTMLStyle4,
373 NULL
376 static const IID * const cstyle_iids[] = {
377 &IID_IUnknown,
378 &IID_IDispatch,
379 &IID_IDispatchEx,
380 &IID_IHTMLCurrentStyle,
381 NULL
384 static const IID * const img_factory_iids[] = {
385 &IID_IUnknown,
386 &IID_IDispatch,
387 &IID_IDispatchEx,
388 &IID_IHTMLImageElementFactory,
389 NULL
392 typedef struct {
393 const char *tag;
394 REFIID *iids;
395 const IID *dispiid;
396 } elem_type_info_t;
398 static const elem_type_info_t elem_type_infos[] = {
399 {"", none_iids, NULL},
400 {"HTML", elem_iids, NULL},
401 {"HEAD", elem_iids, NULL},
402 {"TITLE", elem_iids, NULL},
403 {"BODY", body_iids, &DIID_DispHTMLBody},
404 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
405 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
406 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
407 {"TEXTAREA", textarea_iids, &DIID_DispHTMLTextAreaElement},
408 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
409 {"STYLE", elem_iids, NULL},
410 {"BLOCKQUOTE",elem_iids, NULL},
411 {"P", elem_iids, NULL},
412 {"BR", elem_iids, NULL},
413 {"TABLE", table_iids, &DIID_DispHTMLTable},
414 {"TBODY", elem_iids, NULL},
415 {"SCRIPT", script_iids, &DIID_DispHTMLScriptElement},
416 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
417 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
418 {"!", comment_iids, &DIID_DispHTMLCommentElement},
419 {"IMG", img_iids, &DIID_DispHTMLImg},
420 {"TR", tr_iids, &DIID_DispHTMLTableRow},
421 {"TD", td_iids, NULL},
422 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame},
423 {"FORM", form_iids, &DIID_DispHTMLFormElement},
424 {"FRAME", frame_iids, &DIID_DispHTMLFrameElement}
427 static const char *dbgstr_guid(REFIID riid)
429 static char buf[50];
431 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
432 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
433 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
434 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
436 return buf;
439 static int strcmp_wa(LPCWSTR strw, const char *stra)
441 CHAR buf[512];
442 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
443 return lstrcmpA(stra, buf);
446 static BSTR a2bstr(const char *str)
448 BSTR ret;
449 int len;
451 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
452 ret = SysAllocStringLen(NULL, len);
453 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
455 return ret;
458 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
460 IUnknown *unk1, *unk2;
462 if(iface1 == iface2)
463 return TRUE;
465 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
466 IUnknown_Release(unk1);
467 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
468 IUnknown_Release(unk2);
470 return unk1 == unk2;
473 static IHTMLDocument2 *create_document(void)
475 IHTMLDocument2 *doc;
476 IHTMLDocument5 *doc5;
477 HRESULT hres;
479 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
480 &IID_IHTMLDocument2, (void**)&doc);
481 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
482 if(FAILED(hres))
483 return NULL;
485 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
486 if(FAILED(hres)) {
487 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
488 IHTMLDocument2_Release(doc);
489 return NULL;
492 IHTMLDocument5_Release(doc5);
493 return doc;
496 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
497 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
499 const IID * const *piid;
500 IUnknown *unk;
501 HRESULT hres;
503 for(piid = iids; *piid; piid++) {
504 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
505 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
506 if(SUCCEEDED(hres))
507 IUnknown_Release(unk);
511 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
512 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
514 IDispatchEx *dispex;
515 ITypeInfo *typeinfo;
516 BOOL ret = FALSE;
517 UINT ticnt;
518 HRESULT hres;
520 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
521 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
522 if(FAILED(hres))
523 return FALSE;
525 ticnt = 0xdeadbeef;
526 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
527 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
528 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
530 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
531 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
533 if(SUCCEEDED(hres)) {
534 TYPEATTR *type_attr;
536 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
537 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
538 if(hres == S_OK) {
539 *iid = type_attr->guid;
540 ret = TRUE;
543 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
544 ITypeInfo_Release(typeinfo);
547 IDispatchEx_Release(dispex);
548 return ret;
551 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
552 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
554 DISPPARAMS dp = {NULL,NULL,0,0};
555 IDispatchEx *dispex;
556 EXCEPINFO ei;
557 VARIANT var;
558 HRESULT hres;
560 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
561 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
562 if(FAILED(hres))
563 return;
565 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
566 IDispatchEx_Release(dispex);
567 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
569 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
570 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
571 VariantClear(&var);
574 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
575 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
577 IID iid;
579 if(_test_get_dispid(line, unk, &iid))
580 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
582 if(val)
583 _test_disp_value(line, unk, val);
586 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
587 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
589 IID iid;
591 if(_test_get_dispid(line, unk, &iid))
592 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
593 "unexpected guid %s\n", dbgstr_guid(&iid));
595 if(val)
596 _test_disp_value(line, unk, val);
599 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
600 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
602 IHTMLElement *elem;
603 HRESULT hres;
605 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
606 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
607 return elem;
610 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
611 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
613 IHTMLElement2 *elem;
614 HRESULT hres;
616 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
617 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
618 return elem;
621 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
622 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
624 IHTMLElement3 *elem;
625 HRESULT hres;
627 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
628 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
629 return elem;
632 #define get_node_iface(u) _get_node_iface(__LINE__,u)
633 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
635 IHTMLDOMNode *node;
636 HRESULT hres;
638 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
639 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
640 return node;
643 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
644 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
646 IHTMLDOMNode2 *node;
647 HRESULT hres;
649 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
650 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
651 return node;
654 #define get_img_iface(u) _get_img_iface(__LINE__,u)
655 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
657 IHTMLImgElement *img;
658 HRESULT hres;
660 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
661 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
662 return img;
665 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
666 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
668 IHTMLAnchorElement *anchor;
669 HRESULT hres;
671 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
672 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
673 return anchor;
676 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
677 static IHTMLTextAreaElement *_get_textarea_iface(unsigned line, IUnknown *unk)
679 IHTMLTextAreaElement *textarea;
680 HRESULT hres;
682 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextAreaElement, (void**)&textarea);
683 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextAreaElement: %08x\n", hres);
684 return textarea;
687 #define get_select_iface(u) _get_select_iface(__LINE__,u)
688 static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
690 IHTMLSelectElement *select;
691 HRESULT hres;
693 hres = IUnknown_QueryInterface(unk, &IID_IHTMLSelectElement, (void**)&select);
694 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLSelectElement: %08x\n", hres);
695 return select;
698 #define get_form_iface(u) _get_form_iface(__LINE__,u)
699 static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
701 IHTMLFormElement *form;
702 HRESULT hres;
704 hres = IUnknown_QueryInterface(unk, &IID_IHTMLFormElement, (void**)&form);
705 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLFormElement: %08x\n", hres);
706 return form;
709 #define get_text_iface(u) _get_text_iface(__LINE__,u)
710 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
712 IHTMLDOMTextNode *text;
713 HRESULT hres;
715 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
716 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
717 return text;
720 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
721 static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk)
723 IHTMLCommentElement *comment;
724 HRESULT hres;
726 hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment);
727 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres);
728 return comment;
731 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
732 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
734 IHTMLDOMNode *node = _get_node_iface(line, unk);
735 BSTR name;
736 HRESULT hres;
738 hres = IHTMLDOMNode_get_nodeName(node, &name);
739 IHTMLDOMNode_Release(node);
740 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
741 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
743 SysFreeString(name);
746 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
747 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
749 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
750 IDispatch *disp = (void*)0xdeadbeef;
751 IHTMLDocument2 *doc = NULL;
752 HRESULT hres;
754 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
755 IHTMLDOMNode2_Release(node);
756 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
758 if(disp) {
759 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
760 IDispatch_Release(disp);
761 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
764 return doc;
767 #define get_doc_window(d) _get_doc_window(__LINE__,d)
768 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
770 IHTMLWindow2 *window;
771 HRESULT hres;
773 window = NULL;
774 hres = IHTMLDocument2_get_parentWindow(doc, &window);
775 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
776 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
778 return window;
781 #define clone_node(n,d) _clone_node(__LINE__,n,d)
782 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
784 IHTMLDOMNode *node = _get_node_iface(line, unk);
785 IHTMLDOMNode *ret = NULL;
786 HRESULT hres;
788 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
789 IHTMLDOMNode_Release(node);
790 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
791 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
793 return ret;
797 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
798 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
800 IHTMLElement *elem = _get_elem_iface(line, unk);
801 BSTR tag;
802 HRESULT hres;
804 hres = IHTMLElement_get_tagName(elem, &tag);
805 IHTMLElement_Release(elem);
806 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
807 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
809 SysFreeString(tag);
812 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
813 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
815 _test_elem_tag(line, unk, elem_type_infos[type].tag);
816 _test_ifaces(line, unk, elem_type_infos[type].iids);
818 if(elem_type_infos[type].dispiid && type != ET_A)
819 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
822 #define get_node_type(n) _get_node_type(__LINE__,n)
823 static LONG _get_node_type(unsigned line, IUnknown *unk)
825 IHTMLDOMNode *node = _get_node_iface(line, unk);
826 LONG type = -1;
827 HRESULT hres;
829 hres = IHTMLDOMNode_get_nodeType(node, &type);
830 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
832 IHTMLDOMNode_Release(node);
834 return type;
837 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
838 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
840 IHTMLDOMNode *node = _get_node_iface(line, unk);
841 IHTMLDOMChildrenCollection *col = NULL;
842 IDispatch *disp;
843 HRESULT hres;
845 hres = IHTMLDOMNode_get_childNodes(node, &disp);
846 IHTMLDOMNode_Release(node);
847 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
848 if(FAILED(hres))
849 return NULL;
851 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
852 IDispatch_Release(disp);
853 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
855 return col;
858 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
859 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
861 IHTMLDOMNode *node = NULL;
862 IDispatch *disp;
863 HRESULT hres;
865 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
866 ok(hres == S_OK, "item failed: %08x\n", hres);
868 node = _get_node_iface(line, (IUnknown*)disp);
869 IDispatch_Release(disp);
871 return node;
874 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
875 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
877 VARIANT value;
878 BSTR tmp;
879 HRESULT hres;
881 VariantInit(&value);
883 tmp = a2bstr(name);
884 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
885 SysFreeString(tmp);
886 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
888 if(exval) {
889 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
890 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
891 }else {
892 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
895 VariantClear(&value);
898 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
899 static void _test_elem_offset(unsigned line, IUnknown *unk)
901 IHTMLElement *elem = _get_elem_iface(line, unk);
902 LONG l;
903 HRESULT hres;
905 hres = IHTMLElement_get_offsetTop(elem, &l);
906 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
908 hres = IHTMLElement_get_offsetHeight(elem, &l);
909 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
911 hres = IHTMLElement_get_offsetWidth(elem, &l);
912 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
914 IHTMLElement_Release(elem);
917 #define get_doc_node(d) _get_doc_node(__LINE__,d)
918 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
920 IHTMLWindow2 *window;
921 IHTMLDocument2 *ret;
922 HRESULT hres;
924 hres = IHTMLDocument2_get_parentWindow(doc, &window);
925 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
927 hres = IHTMLWindow2_get_document(window, &ret);
928 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
929 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
931 return ret;
934 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
935 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
937 BSTR name;
938 HRESULT hres;
940 hres = IHTMLWindow2_get_name(window, &name);
941 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
942 if(exname)
943 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
944 else
945 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
948 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
949 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
951 BSTR str;
952 HRESULT hres;
954 str = a2bstr(name);
955 hres = IHTMLWindow2_put_name(window, str);
956 SysFreeString(str);
957 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
959 _test_window_name(line, window, name);
962 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
963 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
965 LONG length = -1;
966 HRESULT hres;
968 hres = IHTMLWindow2_get_length(window, &length);
969 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
970 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
973 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
974 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
976 IHTMLFrameBase2 *base2;
977 IHTMLWindow2 *window;
978 HRESULT hres;
980 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
981 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
983 window = NULL;
984 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
985 IHTMLFrameBase2_Release(base2);
986 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
987 ok(window != NULL, "contentWindow = NULL\n");
989 return window;
992 static void test_get_set_attr(IHTMLDocument2 *doc)
994 IHTMLElement *elem;
995 IHTMLDocument3 *doc3;
996 HRESULT hres;
997 BSTR bstr;
998 VARIANT val;
1000 /* grab an element to test with */
1001 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1002 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
1004 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1005 IHTMLDocument3_Release(doc3);
1006 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
1008 /* get a non-present attribute */
1009 bstr = a2bstr("notAnAttribute");
1010 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1011 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1012 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
1013 VariantClear(&val);
1014 SysFreeString(bstr);
1016 /* get a present attribute */
1017 bstr = a2bstr("scrollHeight");
1018 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1019 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1020 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
1021 VariantClear(&val);
1022 SysFreeString(bstr);
1024 /* create a new BSTR attribute */
1025 bstr = a2bstr("newAttribute");
1027 V_VT(&val) = VT_BSTR;
1028 V_BSTR(&val) = a2bstr("the value");
1029 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1030 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1031 VariantClear(&val);
1033 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1034 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1035 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
1036 ok(strcmp_wa(V_BSTR(&val), "the value") == 0, "variant value should have been L\"the value\", was %s\n", wine_dbgstr_w(V_BSTR(&val)));
1037 VariantClear(&val);
1039 /* overwrite the attribute with a BOOL */
1040 V_VT(&val) = VT_BOOL;
1041 V_BOOL(&val) = VARIANT_TRUE;
1042 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1043 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1044 VariantClear(&val);
1046 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1047 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1048 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1049 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1050 VariantClear(&val);
1052 SysFreeString(bstr);
1054 /* case-insensitive */
1055 bstr = a2bstr("newattribute");
1056 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1057 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1058 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1059 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1060 VariantClear(&val);
1061 SysFreeString(bstr);
1063 IHTMLElement_Release(elem);
1066 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1067 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1069 IHTMLElement *elem;
1070 IHTMLDocument3 *doc3;
1071 HRESULT hres;
1073 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1074 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1075 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1076 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1077 IHTMLDocument3_Release(doc3);
1079 return elem;
1082 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1083 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1085 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1086 BSTR str;
1087 HRESULT hres;
1089 hres = IHTMLAnchorElement_get_href(anchor, &str);
1090 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1091 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1092 SysFreeString(str);
1094 _test_disp_value(line, unk, exhref);
1097 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1098 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1100 BSTR bstr;
1101 HRESULT hres;
1103 hres = IHTMLOptionElement_get_text(option, &bstr);
1104 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1105 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1106 SysFreeString(bstr);
1109 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1110 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1112 BSTR bstr;
1113 HRESULT hres;
1115 bstr = a2bstr(text);
1116 hres = IHTMLOptionElement_put_text(option, bstr);
1117 SysFreeString(bstr);
1118 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1120 _test_option_text(line, option, text);
1123 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1124 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1126 BSTR bstr;
1127 HRESULT hres;
1129 hres = IHTMLOptionElement_get_value(option, &bstr);
1130 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1131 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1132 SysFreeString(bstr);
1135 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1136 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1138 BSTR bstr;
1139 HRESULT hres;
1141 bstr = a2bstr(value);
1142 hres = IHTMLOptionElement_put_value(option, bstr);
1143 SysFreeString(bstr);
1144 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1146 _test_option_value(line, option, value);
1149 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1150 static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
1152 VARIANT_BOOL b = 0x100;
1153 HRESULT hres;
1155 hres = IHTMLOptionElement_get_selected(option, &b);
1156 ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
1157 ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
1160 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1161 static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
1163 HRESULT hres;
1165 hres = IHTMLOptionElement_put_selected(option, b);
1166 ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
1167 _test_option_selected(line, option, b);
1170 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1171 static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
1173 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1174 BSTR value = (void*)0xdeadbeef;
1175 HRESULT hres;
1177 hres = IHTMLTextAreaElement_get_value(textarea, &value);
1178 IHTMLTextAreaElement_Release(textarea);
1179 ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres);
1180 if(exval)
1181 ok_(__FILE__,line)(!strcmp_wa(value, exval), "value = %s, expected %s\n", wine_dbgstr_w(value), exval);
1182 else
1183 ok_(__FILE__,line)(!value, "value = %p\n", value);
1184 SysFreeString(value);
1187 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1188 static void _test_textarea_put_value(unsigned line, IUnknown *unk, const char *value)
1190 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1191 BSTR tmp = a2bstr(value);
1192 HRESULT hres;
1194 hres = IHTMLTextAreaElement_put_value(textarea, tmp);
1195 IHTMLTextAreaElement_Release(textarea);
1196 ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres);
1197 SysFreeString(tmp);
1199 _test_textarea_value(line, unk, value);
1202 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1203 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1205 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1206 BSTR text;
1207 HRESULT hres;
1209 text = a2bstr(extext);
1210 hres = IHTMLCommentElement_get_text(comment, &text);
1211 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1212 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1214 IHTMLCommentElement_Release(comment);
1215 SysFreeString(text);
1218 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1219 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1220 const char *txt, const char *val)
1222 IHTMLOptionElementFactory *factory;
1223 IHTMLOptionElement *option;
1224 IHTMLWindow2 *window;
1225 VARIANT text, value, empty;
1226 HRESULT hres;
1228 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1229 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1231 hres = IHTMLWindow2_get_Option(window, &factory);
1232 IHTMLWindow2_Release(window);
1233 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1235 V_VT(&text) = VT_BSTR;
1236 V_BSTR(&text) = a2bstr(txt);
1237 V_VT(&value) = VT_BSTR;
1238 V_BSTR(&value) = a2bstr(val);
1239 V_VT(&empty) = VT_EMPTY;
1241 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1242 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1244 IHTMLOptionElementFactory_Release(factory);
1245 VariantClear(&text);
1246 VariantClear(&value);
1248 _test_option_text(line, option, txt);
1249 _test_option_value(line, option, val);
1250 _test_option_selected(line, option, VARIANT_FALSE);
1252 return option;
1255 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1256 static void _test_img_width(unsigned line, IHTMLImgElement *img, const LONG exp)
1258 LONG found = -1;
1259 HRESULT hres;
1261 hres = IHTMLImgElement_get_width(img, &found);
1262 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1263 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1266 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1267 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const LONG width)
1269 HRESULT hres;
1271 hres = IHTMLImgElement_put_width(img, width);
1272 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1274 _test_img_width(line, img, width);
1277 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1278 static void _test_img_height(unsigned line, IHTMLImgElement *img, const LONG exp)
1280 LONG found = -1;
1281 HRESULT hres;
1283 hres = IHTMLImgElement_get_height(img, &found);
1284 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1285 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1288 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1289 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const LONG height)
1291 HRESULT hres;
1293 hres = IHTMLImgElement_put_height(img, height);
1294 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1296 _test_img_height(line, img, height);
1299 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1300 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1301 LONG wdth, LONG hght)
1303 IHTMLImageElementFactory *factory;
1304 IHTMLImgElement *img;
1305 IHTMLWindow2 *window;
1306 VARIANT width, height;
1307 char buf[16];
1308 HRESULT hres;
1310 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1311 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1313 hres = IHTMLWindow2_get_Image(window, &factory);
1314 IHTMLWindow2_Release(window);
1315 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1317 test_ifaces((IUnknown*)factory, img_factory_iids);
1318 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1320 if(wdth >= 0){
1321 snprintf(buf, 16, "%d", wdth);
1322 V_VT(&width) = VT_BSTR;
1323 V_BSTR(&width) = a2bstr(buf);
1324 }else{
1325 V_VT(&width) = VT_EMPTY;
1326 wdth = 0;
1329 if(hght >= 0){
1330 snprintf(buf, 16, "%d", hght);
1331 V_VT(&height) = VT_BSTR;
1332 V_BSTR(&height) = a2bstr(buf);
1333 }else{
1334 V_VT(&height) = VT_EMPTY;
1335 hght = 0;
1338 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1339 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1341 IHTMLImageElementFactory_Release(factory);
1342 VariantClear(&width);
1343 VariantClear(&height);
1345 if(SUCCEEDED(hres)) {
1346 _test_img_width(line, img, wdth);
1347 _test_img_height(line, img, hght);
1348 return img;
1351 return NULL;
1354 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1355 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1357 LONG len = 0xdeadbeef;
1358 HRESULT hres;
1360 hres = IHTMLSelectElement_get_length(select, &len);
1361 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1362 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1365 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1366 static void _test_select_put_length(unsigned line, IUnknown *unk, LONG length)
1368 IHTMLSelectElement *select = _get_select_iface(line, unk);
1369 HRESULT hres;
1371 hres = IHTMLSelectElement_put_length(select, length);
1372 ok_(__FILE__,line) (hres == S_OK, "put_length failed: %08x\n", hres);
1373 _test_select_length(line, select, length);
1374 IHTMLSelectElement_Release(select);
1377 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1378 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1380 LONG idx = 0xdeadbeef;
1381 HRESULT hres;
1383 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1384 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1385 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1388 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1389 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1391 HRESULT hres;
1393 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1394 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1395 _test_select_selidx(line, select, index);
1398 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1399 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1401 BSTR val;
1402 HRESULT hres;
1404 hres = IHTMLSelectElement_get_value(select, &val);
1405 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1406 if(exval)
1407 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1408 else
1409 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1412 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1413 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1415 BSTR bstr;
1416 HRESULT hres;
1418 bstr = a2bstr(val);
1419 hres = IHTMLSelectElement_put_value(select, bstr);
1420 SysFreeString(bstr);
1421 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1424 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1425 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1427 BSTR type;
1428 HRESULT hres;
1430 hres = IHTMLSelectElement_get_type(select, &type);
1431 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1432 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1435 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1436 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1438 BSTR text;
1439 HRESULT hres;
1441 hres = IHTMLTxtRange_get_text(range, &text);
1442 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1444 if(extext) {
1445 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1446 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1447 }else {
1448 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1451 SysFreeString(text);
1455 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1456 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1458 HRESULT hres;
1460 hres = IHTMLTxtRange_collapse(range, b);
1461 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1462 _test_range_text(line, range, NULL);
1465 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1466 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1467 VARIANT_BOOL exb, const char *extext)
1469 VARIANT_BOOL b = 0xe0e0;
1470 HRESULT hres;
1472 hres = IHTMLTxtRange_expand(range, unit, &b);
1473 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1474 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1475 _test_range_text(line, range, extext);
1478 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1479 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1481 LONG c = 0xdeadbeef;
1482 HRESULT hres;
1484 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1485 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1486 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1487 _test_range_text(line, range, NULL);
1490 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1491 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1492 LPWSTR unit, LONG cnt, LONG excnt)
1494 LONG c = 0xdeadbeef;
1495 HRESULT hres;
1497 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1498 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1499 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1502 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1503 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1505 LONG c = 0xdeadbeef;
1506 HRESULT hres;
1508 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1509 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1510 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1513 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1514 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1516 HRESULT hres;
1517 BSTR bstr = a2bstr(text);
1519 hres = IHTMLTxtRange_put_text(range, bstr);
1520 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1521 SysFreeString(bstr);
1522 _test_range_text(line, range, NULL);
1525 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1526 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1528 VARIANT_BOOL b;
1529 HRESULT hres;
1531 b = 0xe0e0;
1532 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1533 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1534 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1537 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1538 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1540 VARIANT_BOOL b;
1541 HRESULT hres;
1543 b = 0xe0e0;
1544 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1545 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1546 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1548 b = 0xe0e0;
1549 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1550 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1551 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1553 if(exb) {
1554 test_range_inrange(range1, range2, VARIANT_TRUE);
1555 test_range_inrange(range2, range1, VARIANT_TRUE);
1559 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1560 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1562 IHTMLElement *elem;
1563 HRESULT hres;
1565 hres = IHTMLTxtRange_parentElement(range, &elem);
1566 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1568 _test_elem_type(line, (IUnknown*)elem, type);
1570 IHTMLElement_Release(elem);
1573 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1574 static void _test_elem_collection(unsigned line, IUnknown *unk,
1575 const elem_type_t *elem_types, LONG exlen)
1577 IHTMLElementCollection *col;
1578 LONG len;
1579 DWORD i;
1580 VARIANT name, index;
1581 IDispatch *disp, *disp2;
1582 HRESULT hres;
1584 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1585 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1587 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1589 hres = IHTMLElementCollection_get_length(col, &len);
1590 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1591 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1593 if(len > exlen)
1594 len = exlen;
1596 V_VT(&index) = VT_EMPTY;
1598 for(i=0; i<len; i++) {
1599 V_VT(&name) = VT_I4;
1600 V_I4(&name) = i;
1601 disp = (void*)0xdeadbeef;
1602 hres = IHTMLElementCollection_item(col, name, index, &disp);
1603 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1604 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1605 if(FAILED(hres) || !disp)
1606 continue;
1608 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1610 if(!i) {
1611 V_VT(&name) = VT_UINT;
1612 V_I4(&name) = 0;
1613 disp2 = (void*)0xdeadbeef;
1614 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1615 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1616 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1617 if(disp2)
1618 IDispatch_Release(disp2);
1621 IDispatch_Release(disp);
1624 V_VT(&name) = VT_I4;
1625 V_I4(&name) = len;
1626 disp = (void*)0xdeadbeef;
1627 hres = IHTMLElementCollection_item(col, name, index, &disp);
1628 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1629 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1631 V_VT(&name) = VT_I4;
1632 V_I4(&name) = -1;
1633 disp = (void*)0xdeadbeef;
1634 hres = IHTMLElementCollection_item(col, name, index, &disp);
1635 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1636 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1638 IHTMLElementCollection_Release(col);
1641 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1642 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1644 IHTMLElement *elem = _get_elem_iface(line, unk);
1645 IDispatch *disp;
1646 HRESULT hres;
1648 hres = IHTMLElement_get_all(elem, &disp);
1649 IHTMLElement_Release(elem);
1650 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1652 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1653 IDispatch_Release(disp);
1656 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1657 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1659 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1660 IHTMLElementCollection *col = NULL;
1661 elem_type_t *types = NULL;
1662 BSTR tmp;
1663 int i;
1664 HRESULT hres;
1666 tmp = a2bstr(elem_type_infos[type].tag);
1667 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1668 SysFreeString(tmp);
1669 IHTMLElement2_Release(elem);
1670 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1671 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1673 if(exlen) {
1674 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1675 for(i=0; i<exlen; i++)
1676 types[i] = type;
1679 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1681 HeapFree(GetProcessHeap(), 0, types);
1684 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1685 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1687 BSTR text = NULL;
1688 HRESULT hres;
1690 hres = IHTMLElement_get_innerText(elem, &text);
1691 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1692 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1693 wine_dbgstr_w(text), extext);
1694 SysFreeString(text);
1697 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1698 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1700 IHTMLDOMChildrenCollection *col;
1701 BSTR str;
1702 HRESULT hres;
1704 str = a2bstr(text);
1705 hres = IHTMLElement_put_innerText(elem, str);
1706 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1707 SysFreeString(str);
1709 _test_elem_innertext(line, elem, text);
1712 col = _get_child_nodes(line, (IUnknown*)elem);
1713 ok(col != NULL, "col == NULL\n");
1714 if(col) {
1715 LONG length = 0, type;
1716 IHTMLDOMNode *node;
1718 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1719 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1720 ok(length == 1, "length = %d\n", length);
1722 node = _get_child_item(line, col, 0);
1723 ok(node != NULL, "node == NULL\n");
1724 if(node) {
1725 type = _get_node_type(line, (IUnknown*)node);
1726 ok(type == 3, "type=%d\n", type);
1727 IHTMLDOMNode_Release(node);
1730 IHTMLDOMChildrenCollection_Release(col);
1735 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1736 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1738 IHTMLElement *elem = _get_elem_iface(line, unk);
1739 BSTR html;
1740 HRESULT hres;
1742 hres = IHTMLElement_get_innerHTML(elem, &html);
1743 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1744 if(inner_html)
1745 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1746 else
1747 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1749 IHTMLElement_Release(elem);
1750 SysFreeString(html);
1753 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1754 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1756 IHTMLElement *elem = _get_elem_iface(line, unk);
1757 BSTR html;
1758 HRESULT hres;
1760 html = a2bstr(inner_html);
1761 hres = IHTMLElement_put_innerHTML(elem, html);
1762 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1764 IHTMLElement_Release(elem);
1765 SysFreeString(html);
1768 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1769 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1771 IHTMLElement *elem = _get_elem_iface(line, unk);
1772 BSTR html;
1773 HRESULT hres;
1775 html = a2bstr(outer_html);
1776 hres = IHTMLElement_put_outerHTML(elem, html);
1777 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1779 IHTMLElement_Release(elem);
1780 SysFreeString(html);
1783 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1784 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1786 IHTMLElement *elem = _get_elem_iface(line, unk);
1787 BSTR html;
1788 HRESULT hres;
1790 hres = IHTMLElement_get_outerHTML(elem, &html);
1791 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
1792 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
1794 IHTMLElement_Release(elem);
1795 SysFreeString(html);
1798 #define get_first_child(n) _get_first_child(__LINE__,n)
1799 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1801 IHTMLDOMNode *node = _get_node_iface(line, unk);
1802 IHTMLDOMNode *child = NULL;
1803 HRESULT hres;
1805 hres = IHTMLDOMNode_get_firstChild(node, &child);
1806 IHTMLDOMNode_Release(node);
1807 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1809 return child;
1812 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1813 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1815 IHTMLDOMNode *node = _get_node_iface(line, unk);
1816 VARIANT_BOOL b = 0xdead;
1817 HRESULT hres;
1819 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1820 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1821 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1823 IHTMLDOMNode_Release(node);
1826 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1827 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1829 IHTMLDOMNode *node = _get_node_iface(line, unk);
1830 IHTMLDOMNode *parent;
1831 HRESULT hres;
1833 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1834 IHTMLDOMNode_Release(node);
1835 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1837 return parent;
1840 #define node_get_next(u) _node_get_next(__LINE__,u)
1841 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1843 IHTMLDOMNode *node = _get_node_iface(line, unk);
1844 IHTMLDOMNode *next;
1845 HRESULT hres;
1847 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1848 IHTMLDOMNode_Release(node);
1849 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1851 return next;
1854 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1855 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1857 IHTMLElement *elem = _get_elem_iface(line, unk);
1858 IHTMLElement *parent;
1859 HRESULT hres;
1861 hres = IHTMLElement_get_parentElement(elem, &parent);
1862 IHTMLElement_Release(elem);
1863 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1865 return parent;
1868 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1869 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1871 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1872 VARIANT_BOOL disabled = 100;
1873 HRESULT hres;
1875 if (!elem3) return;
1876 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1877 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1878 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1879 IHTMLElement3_Release(elem3);
1882 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1883 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1885 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1886 HRESULT hres;
1888 if (!elem3) return;
1889 hres = IHTMLElement3_put_disabled(elem3, b);
1890 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1892 IHTMLElement3_Release(elem3);
1893 _test_elem3_get_disabled(line, unk, b);
1896 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1897 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1899 VARIANT_BOOL disabled = 100;
1900 HRESULT hres;
1902 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1903 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1904 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1906 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1909 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
1910 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
1912 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
1913 LONG length;
1914 HRESULT hres;
1916 hres = IHTMLDOMTextNode_get_length(text, &length);
1917 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
1918 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
1919 IHTMLDOMTextNode_Release(text);
1922 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1923 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1925 HRESULT hres;
1927 hres = IHTMLSelectElement_put_disabled(select, b);
1928 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1930 _test_select_get_disabled(line, select, b);
1933 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1934 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1936 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1937 IHTMLTextContainer *txtcont;
1938 LONG l = -1, l2 = -1;
1939 HRESULT hres;
1941 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1942 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1943 IHTMLElement2_Release(elem);
1945 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1946 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1948 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1949 IHTMLTextContainer_Release(txtcont);
1950 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1951 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1953 return l;
1956 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1957 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1959 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1960 IHTMLTextContainer *txtcont;
1961 LONG l = -1, l2 = -1;
1962 HRESULT hres;
1964 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1965 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1966 IHTMLElement2_Release(elem);
1968 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1969 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1971 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1972 IHTMLTextContainer_Release(txtcont);
1973 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1974 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1976 return l;
1979 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1980 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1982 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1983 IHTMLTextContainer *txtcont;
1984 LONG l = -1, l2 = -1;
1985 HRESULT hres;
1987 hres = IHTMLElement2_get_scrollTop(elem, &l);
1988 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1989 IHTMLElement2_Release(elem);
1991 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1992 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1994 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1995 IHTMLTextContainer_Release(txtcont);
1996 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1997 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1999 return l;
2002 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2003 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
2005 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2006 IHTMLTextContainer *txtcont;
2007 LONG l = -1, l2 = -1;
2008 HRESULT hres;
2010 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
2011 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
2013 hres = IHTMLElement2_get_scrollLeft(elem, &l);
2014 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2015 IHTMLElement2_Release(elem);
2017 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2018 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2020 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
2021 IHTMLTextContainer_Release(txtcont);
2022 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
2023 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
2026 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
2027 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
2029 IHTMLImgElement *img = _get_img_iface(line, unk);
2030 BSTR src;
2031 HRESULT hres;
2033 hres = IHTMLImgElement_get_src(img, &src);
2034 IHTMLImgElement_Release(img);
2035 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2036 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2037 SysFreeString(src);
2040 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2041 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
2043 IHTMLImgElement *img = _get_img_iface(line, unk);
2044 BSTR tmp;
2045 HRESULT hres;
2047 tmp = a2bstr(src);
2048 hres = IHTMLImgElement_put_src(img, tmp);
2049 IHTMLImgElement_Release(img);
2050 SysFreeString(tmp);
2051 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2053 _test_img_src(line, unk, src);
2056 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2057 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
2059 IHTMLImgElement *img = _get_img_iface(line, unk);
2060 BSTR alt;
2061 HRESULT hres;
2063 hres = IHTMLImgElement_get_alt(img, &alt);
2064 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2065 if(exalt)
2066 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
2067 else
2068 ok_(__FILE__,line) (!alt, "alt != NULL\n");
2069 SysFreeString(alt);
2072 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2073 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
2075 IHTMLImgElement *img = _get_img_iface(line, unk);
2076 BSTR tmp;
2077 HRESULT hres;
2079 tmp = a2bstr(alt);
2080 hres = IHTMLImgElement_put_alt(img, tmp);
2081 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2082 SysFreeString(tmp);
2084 _test_img_alt(line, unk, alt);
2087 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2088 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
2090 IHTMLImgElement *img = _get_img_iface(line, unk);
2091 BSTR sName;
2092 HRESULT hres;
2094 hres = IHTMLImgElement_get_name(img, &sName);
2095 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
2096 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
2097 IHTMLImgElement_Release(img);
2098 SysFreeString(sName);
2101 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2102 static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype)
2104 BSTR type;
2105 HRESULT hres;
2107 hres = IHTMLInputElement_get_type(input, &type);
2108 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
2109 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
2110 SysFreeString(type);
2113 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2114 static void _test_input_name(unsigned line, IHTMLInputElement *input, const char *exname)
2116 BSTR name = (BSTR)0xdeadbeef;
2117 HRESULT hres;
2119 hres = IHTMLInputElement_get_name(input, &name);
2120 ok_(__FILE__,line) (hres == S_OK, "get_name failed: %08x\n", hres);
2121 if(exname)
2122 ok_(__FILE__,line) (!strcmp_wa (name, exname), "name=%s, expected %s\n", wine_dbgstr_w(name), exname);
2123 else
2124 ok_(__FILE__,line) (!name, "name=%p, expected NULL\n", name);
2125 SysFreeString(name);
2128 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2129 static void _test_input_set_name(unsigned line, IHTMLInputElement *input, const char *name)
2131 BSTR tmp = a2bstr(name);
2132 HRESULT hres;
2134 hres = IHTMLInputElement_put_name(input, tmp);
2135 ok_(__FILE__,line) (hres == S_OK, "put_name failed: %08x\n", hres);
2136 SysFreeString(tmp);
2138 _test_input_name(line, input, name);
2141 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2142 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2144 VARIANT_BOOL disabled = 100;
2145 HRESULT hres;
2147 hres = IHTMLInputElement_get_disabled(input, &disabled);
2148 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2149 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2151 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2154 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2155 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2157 HRESULT hres;
2159 hres = IHTMLInputElement_put_disabled(input, b);
2160 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2162 _test_input_get_disabled(line, input, b);
2165 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2166 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2168 VARIANT_BOOL checked = 100;
2169 HRESULT hres;
2171 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2172 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2173 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2176 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2177 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2179 HRESULT hres;
2181 hres = IHTMLInputElement_put_defaultChecked(input, b);
2182 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2184 _test_input_get_defaultchecked(line, input, b);
2187 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2188 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2190 VARIANT_BOOL checked = 100;
2191 HRESULT hres;
2193 hres = IHTMLInputElement_get_checked(input, &checked);
2194 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2195 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2198 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2199 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2201 HRESULT hres;
2203 hres = IHTMLInputElement_put_checked(input, b);
2204 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2206 _test_input_get_checked(line, input, b);
2209 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2210 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2212 IHTMLInputElement *input;
2213 BSTR bstr;
2214 HRESULT hres;
2216 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2217 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2218 if(FAILED(hres))
2219 return;
2221 hres = IHTMLInputElement_get_value(input, &bstr);
2222 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2223 if(exval)
2224 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2225 else
2226 ok_(__FILE__,line) (!exval, "exval != NULL\n");
2227 SysFreeString(bstr);
2228 IHTMLInputElement_Release(input);
2231 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2232 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2234 IHTMLInputElement *input;
2235 BSTR bstr;
2236 HRESULT hres;
2238 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2239 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2240 if(FAILED(hres))
2241 return;
2243 bstr = a2bstr(val);
2244 hres = IHTMLInputElement_get_value(input, &bstr);
2245 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2246 SysFreeString(bstr);
2247 IHTMLInputElement_Release(input);
2250 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2251 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2253 BSTR src;
2254 HRESULT hres;
2256 hres = IHTMLInputElement_get_src(input, &src);
2257 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2258 if(exsrc)
2259 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2260 else
2261 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2262 SysFreeString(src);
2265 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2266 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2268 BSTR tmp;
2269 HRESULT hres;
2271 tmp = a2bstr(src);
2272 hres = IHTMLInputElement_put_src(input, tmp);
2273 SysFreeString(tmp);
2274 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2276 _test_input_src(line, input, src);
2279 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2280 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2282 IHTMLElement *elem = _get_elem_iface(line, unk);
2283 BSTR class = (void*)0xdeadbeef;
2284 HRESULT hres;
2286 hres = IHTMLElement_get_className(elem, &class);
2287 IHTMLElement_Release(elem);
2288 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2289 if(exclass)
2290 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2291 else
2292 ok_(__FILE__,line) (!class, "class != NULL\n");
2293 SysFreeString(class);
2296 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2297 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2299 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2300 short index = -3;
2301 HRESULT hres;
2303 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2304 IHTMLElement2_Release(elem2);
2305 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2306 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2309 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2310 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2312 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2313 HRESULT hres;
2315 hres = IHTMLElement2_put_tabIndex(elem2, index);
2316 IHTMLElement2_Release(elem2);
2317 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2319 _test_elem_tabindex(line, unk, index);
2322 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2323 static void _test_elem_filters(unsigned line, IUnknown *unk)
2325 IHTMLElement *elem = _get_elem_iface(line, unk);
2326 HRESULT hres;
2327 IHTMLFiltersCollection *filters;
2329 hres = IHTMLElement_get_filters(elem, &filters);
2330 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2331 "get_filters failed: %08x\n", hres);
2332 if(hres == S_OK)
2334 LONG len;
2335 IDispatchEx *dispex;
2337 hres = IHTMLFiltersCollection_get_length(filters, &len);
2338 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2339 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2341 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2342 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2343 "Could not get IDispatchEx interface: %08x\n", hres);
2344 if(SUCCEEDED(hres)) {
2345 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2346 IDispatchEx_Release(dispex);
2349 IHTMLFiltersCollection_Release(filters);
2352 IHTMLElement_Release(elem);
2355 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2356 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2358 IHTMLElement *elem = _get_elem_iface(line, unk);
2359 BSTR tmp;
2360 HRESULT hres;
2362 tmp = class ? a2bstr(class) : NULL;
2363 hres = IHTMLElement_put_className(elem, tmp);
2364 IHTMLElement_Release(elem);
2365 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2366 SysFreeString(tmp);
2368 _test_elem_class(line, unk, class);
2371 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2372 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2374 IHTMLElement *elem = _get_elem_iface(line, unk);
2375 BSTR id = (void*)0xdeadbeef;
2376 HRESULT hres;
2378 hres = IHTMLElement_get_id(elem, &id);
2379 IHTMLElement_Release(elem);
2380 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2382 if(exid)
2383 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2384 else
2385 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2387 SysFreeString(id);
2390 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2391 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2393 IHTMLElement *elem = _get_elem_iface(line, unk);
2394 BSTR tmp = a2bstr(new_id);
2395 HRESULT hres;
2397 hres = IHTMLElement_put_id(elem, tmp);
2398 IHTMLElement_Release(elem);
2399 SysFreeString(tmp);
2400 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2402 _test_elem_id(line, unk, new_id);
2405 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2406 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2408 IHTMLElement *elem = _get_elem_iface(line, unk);
2409 BSTR title;
2410 HRESULT hres;
2412 hres = IHTMLElement_get_title(elem, &title);
2413 IHTMLElement_Release(elem);
2414 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2415 if(extitle)
2416 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2417 else
2418 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2420 SysFreeString(title);
2423 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2424 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2426 IHTMLElement *elem = _get_elem_iface(line, unk);
2427 BSTR tmp;
2428 HRESULT hres;
2430 tmp = a2bstr(title);
2431 hres = IHTMLElement_put_title(elem, tmp);
2432 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2434 IHTMLElement_Release(elem);
2435 SysFreeString(tmp);
2438 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2439 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2441 IHTMLDOMNode *node = _get_node_iface(line, unk);
2442 VARIANT var;
2443 HRESULT hres;
2445 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2446 IHTMLDOMNode_Release(node);
2447 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2449 if(exval) {
2450 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2451 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2452 }else {
2453 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2456 VariantClear(&var);
2459 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2460 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2462 IHTMLDOMNode *node = _get_node_iface(line, unk);
2463 VARIANT var;
2464 HRESULT hres;
2466 V_VT(&var) = VT_BSTR;
2467 V_BSTR(&var) = a2bstr(val);
2469 hres = IHTMLDOMNode_put_nodeValue(node, var);
2470 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2471 IHTMLDOMNode_Release(node);
2472 VariantClear(&var);
2475 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2476 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2478 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2479 LONG l;
2480 HRESULT hres;
2482 hres = IHTMLElement2_get_clientWidth(elem, &l);
2483 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2484 hres = IHTMLElement2_get_clientHeight(elem, &l);
2485 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2487 IHTMLElement2_Release(elem);
2490 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2491 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2493 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2494 LONG l;
2495 HRESULT hres;
2497 hres = IHTMLElement2_get_clientLeft(elem, &l);
2498 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2499 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2501 hres = IHTMLElement2_get_clientTop(elem, &l);
2502 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2503 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2505 IHTMLElement2_Release(elem);
2508 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2509 static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
2511 IHTMLFormElement *form = _get_form_iface(line, unk);
2512 LONG len = 0xdeadbeef;
2513 HRESULT hres;
2515 hres = IHTMLFormElement_get_length(form, &len);
2516 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2517 ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
2519 IHTMLFormElement_Release(form);
2522 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2523 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2525 IHTMLElement *elem = _get_elem_iface(line, unk);
2526 IHTMLDocument2 *doc;
2527 IDispatch *disp;
2528 HRESULT hres;
2530 disp = NULL;
2531 hres = IHTMLElement_get_document(elem, &disp);
2532 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2533 ok(disp != NULL, "disp == NULL\n");
2535 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2536 IDispatch_Release(disp);
2537 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2539 return doc;
2542 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2543 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2545 IHTMLDocument2 *doc;
2546 HRESULT hres;
2548 doc = NULL;
2549 hres = IHTMLWindow2_get_document(window, &doc);
2550 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2551 ok(doc != NULL, "disp == NULL\n");
2553 return doc;
2556 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2557 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2559 IHTMLElement *elem = NULL;
2560 BSTR tmp;
2561 HRESULT hres;
2563 tmp = a2bstr(tag);
2564 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2565 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2566 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2568 return elem;
2571 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2572 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2574 IHTMLDocument3 *doc3;
2575 IHTMLDOMNode *node = NULL;
2576 BSTR tmp;
2577 HRESULT hres;
2579 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2580 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2582 tmp = a2bstr(text);
2583 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2584 IHTMLDocument3_Release(doc3);
2585 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2586 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2588 return node;
2591 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2592 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2594 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2595 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2596 IHTMLDOMNode *new_child = NULL;
2597 HRESULT hres;
2599 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2600 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2601 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2602 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2604 IHTMLDOMNode_Release(node);
2605 IHTMLDOMNode_Release(child);
2607 return new_child;
2610 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2611 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2613 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2614 IHTMLDOMNode *new_child = NULL;
2615 HRESULT hres;
2617 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2618 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2619 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2620 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2622 IHTMLDOMNode_Release(node);
2624 return new_child;
2627 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2628 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2630 IHTMLDOMNode *node = _get_node_iface(line, unk);
2631 IHTMLDOMNode *new_node = NULL;
2632 HRESULT hres;
2634 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2635 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2636 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2637 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2639 IHTMLDOMNode_Release(node);
2640 IHTMLDOMNode_Release(new_node);
2643 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2644 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2646 BSTR title = NULL;
2647 HRESULT hres;
2649 hres = IHTMLDocument2_get_title(doc, &title);
2650 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2651 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2652 SysFreeString(title);
2655 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2656 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2658 BSTR tmp;
2659 HRESULT hres;
2661 tmp = a2bstr(title);
2662 hres = IHTMLDocument2_put_title(doc, tmp);
2663 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2664 SysFreeString(tmp);
2667 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2668 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2670 HRESULT hres;
2671 DISPID dispid;
2673 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2674 LOCALE_USER_DEFAULT, &dispid);
2675 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2676 if(hres == S_OK)
2678 DISPPARAMS params = {NULL,NULL,0,0};
2679 DISPID dispidNamed = DISPID_PROPERTYPUT;
2680 VARIANT ret;
2681 VARIANT vDefault;
2682 VARIANTARG arg;
2684 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2685 DISPATCH_PROPERTYGET, &params, &vDefault, NULL, NULL);
2686 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2688 params.cArgs = 1;
2689 params.cNamedArgs = 1;
2690 params.rgdispidNamedArgs = &dispidNamed;
2691 V_VT(&arg) = VT_BSTR;
2692 V_BSTR(&arg) = a2bstr("none");
2693 params.rgvarg = &arg;
2694 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2695 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2696 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2697 VariantClear(&arg);
2699 V_VT(&arg) = VT_BSTR;
2700 V_BSTR(&arg) = a2bstr("dotted");
2701 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2702 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2703 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2704 VariantClear(&arg);
2706 V_VT(&arg) = VT_BSTR;
2707 V_BSTR(&arg) = a2bstr("dashed");
2708 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2709 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2710 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2711 VariantClear(&arg);
2713 V_VT(&arg) = VT_BSTR;
2714 V_BSTR(&arg) = a2bstr("solid");
2715 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2716 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2717 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2718 VariantClear(&arg);
2720 V_VT(&arg) = VT_BSTR;
2721 V_BSTR(&arg) = a2bstr("double");
2722 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2723 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2724 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2725 VariantClear(&arg);
2727 V_VT(&arg) = VT_BSTR;
2728 V_BSTR(&arg) = a2bstr("groove");
2729 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2730 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2731 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2732 VariantClear(&arg);
2734 V_VT(&arg) = VT_BSTR;
2735 V_BSTR(&arg) = a2bstr("ridge");
2736 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2737 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2738 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2739 VariantClear(&arg);
2741 V_VT(&arg) = VT_BSTR;
2742 V_BSTR(&arg) = a2bstr("inset");
2743 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2744 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2745 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2746 VariantClear(&arg);
2748 V_VT(&arg) = VT_BSTR;
2749 V_BSTR(&arg) = a2bstr("outset");
2750 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2751 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2752 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2753 VariantClear(&arg);
2755 V_VT(&arg) = VT_BSTR;
2756 V_BSTR(&arg) = a2bstr("invalid");
2757 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2758 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2759 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2760 VariantClear(&arg);
2762 params.rgvarg = &vDefault;
2763 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2764 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2765 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2769 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2770 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2772 BSTR text = (void*)0xdeadbeef;
2773 HRESULT hres;
2775 hres = IHTMLStyle_get_cssText(style, &text);
2776 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2777 if(extext)
2778 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2779 else
2780 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2782 SysFreeString(text);
2785 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2786 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2788 BSTR tmp;
2789 HRESULT hres;
2791 tmp = a2bstr(text);
2792 hres = IHTMLStyle_put_cssText(style, tmp);
2793 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2794 SysFreeString(tmp);
2797 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2798 const elem_type_t *elem_types, LONG len)
2800 IDispatch *disp;
2801 VARIANT name, index;
2802 DWORD i;
2803 HRESULT hres;
2805 V_VT(&index) = VT_EMPTY;
2806 V_VT(&name) = VT_BSTR;
2807 V_BSTR(&name) = a2bstr(n);
2809 hres = IHTMLElementCollection_item(col, name, index, &disp);
2810 ok(hres == S_OK, "item failed: %08x\n", hres);
2812 test_elem_collection((IUnknown*)disp, elem_types, len);
2813 IDispatch_Release(disp);
2814 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2815 if(hres != S_OK)
2816 goto cleanup;
2818 V_VT(&index) = VT_I4;
2820 for(i=0; i<len; i++) {
2821 V_I4(&index) = i;
2822 disp = (void*)0xdeadbeef;
2823 hres = IHTMLElementCollection_item(col, name, index, &disp);
2824 ok(hres == S_OK, "item failed: %08x\n", hres);
2825 ok(disp != NULL, "disp == NULL\n");
2826 if(FAILED(hres) || !disp)
2827 continue;
2829 test_elem_type((IUnknown*)disp, elem_types[i]);
2831 IDispatch_Release(disp);
2834 V_I4(&index) = len;
2835 disp = (void*)0xdeadbeef;
2836 hres = IHTMLElementCollection_item(col, name, index, &disp);
2837 ok(hres == S_OK, "item failed: %08x\n", hres);
2838 ok(disp == NULL, "disp != NULL\n");
2840 V_I4(&index) = -1;
2841 disp = (void*)0xdeadbeef;
2842 hres = IHTMLElementCollection_item(col, name, index, &disp);
2843 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2844 ok(disp == NULL, "disp != NULL\n");
2846 cleanup:
2847 SysFreeString(V_BSTR(&name));
2850 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2852 IHTMLElementCollection *col;
2853 IHTMLElement *elem;
2854 IDispatch *disp = (void*)0xdeadbeef;
2855 VARIANT name, index;
2856 HRESULT hres;
2858 hres = IHTMLDocument2_get_all(doc, &col);
2859 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2860 ok(col != NULL, "col == NULL\n");
2861 if(FAILED(hres) || !col)
2862 return NULL;
2864 V_VT(&index) = VT_EMPTY;
2865 V_VT(&name) = VT_BSTR;
2866 V_BSTR(&name) = a2bstr(id);
2868 hres = IHTMLElementCollection_item(col, name, index, &disp);
2869 IHTMLElementCollection_Release(col);
2870 SysFreeString(V_BSTR(&name));
2871 ok(hres == S_OK, "item failed: %08x\n", hres);
2872 if(!expect_success) {
2873 ok(disp == NULL, "disp != NULL\n");
2874 return NULL;
2877 ok(disp != NULL, "disp == NULL\n");
2878 if(!disp)
2879 return NULL;
2881 elem = get_elem_iface((IUnknown*)disp);
2882 IDispatch_Release(disp);
2884 return elem;
2887 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2889 IHTMLDocument3 *doc3;
2890 IHTMLElement *elem;
2891 BSTR tmp;
2892 HRESULT hres;
2894 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2895 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2897 tmp = a2bstr(id);
2898 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2899 SysFreeString(tmp);
2900 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2902 IHTMLDocument3_Release(doc3);
2904 return elem;
2907 static void test_select_elem(IHTMLSelectElement *select)
2909 IDispatch *disp;
2910 HRESULT hres;
2912 test_select_type(select, "select-one");
2913 test_select_length(select, 2);
2914 test_select_selidx(select, 0);
2915 test_select_put_selidx(select, 1);
2917 test_select_set_value(select, "val1");
2918 test_select_value(select, "val1");
2920 test_select_get_disabled(select, VARIANT_FALSE);
2921 test_select_set_disabled(select, VARIANT_TRUE);
2922 test_select_set_disabled(select, VARIANT_FALSE);
2924 disp = NULL;
2925 hres = IHTMLSelectElement_get_options(select, &disp);
2926 ok(hres == S_OK, "get_options failed: %08x\n", hres);
2927 ok(disp != NULL, "options == NULL\n");
2928 ok(iface_cmp((IUnknown*)disp, (IUnknown*)select), "disp != select\n");
2929 IDispatch_Release(disp);
2932 static void test_create_option_elem(IHTMLDocument2 *doc)
2934 IHTMLOptionElement *option;
2936 option = create_option_elem(doc, "test text", "test value");
2938 test_option_put_text(option, "new text");
2939 test_option_put_value(option, "new value");
2940 test_option_put_selected(option, VARIANT_TRUE);
2941 test_option_put_selected(option, VARIANT_FALSE);
2943 IHTMLOptionElement_Release(option);
2946 static void test_create_img_elem(IHTMLDocument2 *doc)
2948 IHTMLImgElement *img;
2950 img = create_img_elem(doc, 10, 15);
2952 if(img){
2953 test_img_put_width(img, 5);
2954 test_img_put_height(img, 20);
2956 IHTMLImgElement_Release(img);
2957 img = NULL;
2960 img = create_img_elem(doc, -1, -1);
2962 if(img){
2963 test_img_put_width(img, 5);
2964 test_img_put_height(img, 20);
2966 IHTMLImgElement_Release(img);
2970 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2972 IHTMLBodyElement *body;
2973 IHTMLTxtRange *range;
2974 IHTMLElement *elem;
2975 HRESULT hres;
2977 hres = IHTMLDocument2_get_body(doc, &elem);
2978 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2980 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2981 IHTMLElement_Release(elem);
2983 hres = IHTMLBodyElement_createTextRange(body, &range);
2984 IHTMLBodyElement_Release(body);
2985 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2987 return range;
2990 static void test_txtrange(IHTMLDocument2 *doc)
2992 IHTMLTxtRange *body_range, *range, *range2;
2993 IHTMLSelectionObject *selection;
2994 IDispatch *disp_range;
2995 HRESULT hres;
2997 body_range = test_create_body_range(doc);
2999 test_range_text(body_range, "test abc 123\r\nit's text");
3001 hres = IHTMLTxtRange_duplicate(body_range, &range);
3002 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3004 hres = IHTMLTxtRange_duplicate(body_range, &range2);
3005 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3006 test_range_isequal(range, range2, VARIANT_TRUE);
3008 test_range_text(range, "test abc 123\r\nit's text");
3009 test_range_text(body_range, "test abc 123\r\nit's text");
3011 test_range_collapse(range, TRUE);
3012 test_range_isequal(range, range2, VARIANT_FALSE);
3013 test_range_inrange(range, range2, VARIANT_FALSE);
3014 test_range_inrange(range2, range, VARIANT_TRUE);
3015 IHTMLTxtRange_Release(range2);
3017 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3018 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
3019 test_range_move(range, characterW, 2, 2);
3020 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3022 test_range_collapse(range, FALSE);
3023 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
3025 test_range_collapse(range, FALSE);
3026 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3027 test_range_expand(range, wordW, VARIANT_FALSE, "123");
3028 test_range_move(range, characterW, 2, 2);
3029 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3030 test_range_moveend(range, characterW, -5, -5);
3031 test_range_text(range, NULL);
3032 test_range_moveend(range, characterW, 3, 3);
3033 test_range_text(range, "c 1");
3034 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
3035 test_range_collapse(range, TRUE);
3036 test_range_move(range, characterW, 4, 4);
3037 test_range_moveend(range, characterW, 1, 1);
3038 test_range_text(range, " ");
3039 test_range_move(range, wordW, 1, 1);
3040 test_range_moveend(range, characterW, 2, 2);
3041 test_range_text(range, "ab");
3043 IHTMLTxtRange_Release(range);
3045 hres = IHTMLTxtRange_duplicate(body_range, &range);
3046 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3048 test_range_text(range, "test abc 123\r\nit's text");
3049 test_range_move(range, characterW, 3, 3);
3050 test_range_moveend(range, characterW, 1, 1);
3051 test_range_text(range, "t");
3052 test_range_moveend(range, characterW, 3, 3);
3053 test_range_text(range, "t ab");
3054 test_range_moveend(range, characterW, -2, -2);
3055 test_range_text(range, "t ");
3056 test_range_move(range, characterW, 6, 6);
3057 test_range_moveend(range, characterW, 3, 3);
3058 test_range_text(range, "123");
3059 test_range_moveend(range, characterW, 2, 2);
3060 test_range_text(range, "123\r\ni");
3062 IHTMLTxtRange_Release(range);
3064 hres = IHTMLTxtRange_duplicate(body_range, &range);
3065 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3067 test_range_move(range, wordW, 1, 1);
3068 test_range_moveend(range, characterW, 2, 2);
3069 test_range_text(range, "ab");
3071 test_range_move(range, characterW, -2, -2);
3072 test_range_moveend(range, characterW, 2, 2);
3073 test_range_text(range, "t ");
3075 test_range_move(range, wordW, 3, 3);
3076 test_range_move(range, wordW, -2, -2);
3077 test_range_moveend(range, characterW, 2, 2);
3078 test_range_text(range, "ab");
3080 test_range_move(range, characterW, -6, -5);
3081 test_range_moveend(range, characterW, -1, 0);
3082 test_range_moveend(range, characterW, -6, 0);
3083 test_range_move(range, characterW, 2, 2);
3084 test_range_moveend(range, characterW, 2, 2);
3085 test_range_text(range, "st");
3086 test_range_moveend(range, characterW, -6, -4);
3087 test_range_moveend(range, characterW, 2, 2);
3089 IHTMLTxtRange_Release(range);
3091 hres = IHTMLTxtRange_duplicate(body_range, &range);
3092 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3094 test_range_move(range, wordW, 2, 2);
3095 test_range_moveend(range, characterW, 2, 2);
3096 test_range_text(range, "12");
3098 test_range_move(range, characterW, 15, 14);
3099 test_range_move(range, characterW, -2, -2);
3100 test_range_moveend(range, characterW, 3, 2);
3101 test_range_text(range, "t");
3102 test_range_moveend(range, characterW, -1, -1);
3103 test_range_text(range, "t");
3104 test_range_expand(range, wordW, VARIANT_TRUE, "text");
3105 test_range_move(range, characterW, -2, -2);
3106 test_range_moveend(range, characterW, 2, 2);
3107 test_range_text(range, "s ");
3108 test_range_move(range, characterW, 100, 7);
3109 test_range_move(range, wordW, 1, 0);
3110 test_range_move(range, characterW, -2, -2);
3111 test_range_moveend(range, characterW, 3, 2);
3112 test_range_text(range, "t");
3114 IHTMLTxtRange_Release(range);
3116 hres = IHTMLTxtRange_duplicate(body_range, &range);
3117 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3119 test_range_collapse(range, TRUE);
3120 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3121 test_range_put_text(range, "word");
3122 test_range_text(body_range, "wordabc 123\r\nit's text");
3123 test_range_text(range, NULL);
3124 test_range_moveend(range, characterW, 3, 3);
3125 test_range_text(range, "abc");
3126 test_range_movestart(range, characterW, -2, -2);
3127 test_range_text(range, "rdabc");
3128 test_range_movestart(range, characterW, 3, 3);
3129 test_range_text(range, "bc");
3130 test_range_movestart(range, characterW, 4, 4);
3131 test_range_text(range, NULL);
3132 test_range_movestart(range, characterW, -3, -3);
3133 test_range_text(range, "c 1");
3134 test_range_movestart(range, characterW, -7, -6);
3135 test_range_text(range, "wordabc 1");
3136 test_range_movestart(range, characterW, 100, 22);
3137 test_range_text(range, NULL);
3139 IHTMLTxtRange_Release(range);
3140 IHTMLTxtRange_Release(body_range);
3142 hres = IHTMLDocument2_get_selection(doc, &selection);
3143 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
3145 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
3146 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
3147 IHTMLSelectionObject_Release(selection);
3149 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
3150 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
3151 IDispatch_Release(disp_range);
3153 test_range_text(range, NULL);
3154 test_range_moveend(range, characterW, 3, 3);
3155 test_range_text(range, "wor");
3156 test_range_parent(range, ET_BODY);
3157 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3158 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3159 test_range_move(range, characterW, 3, 3);
3160 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
3161 test_range_moveend(range, characterW, -4, -4);
3162 test_range_put_text(range, "abc def ");
3163 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
3164 test_range_move(range, wordW, 1, 1);
3165 test_range_movestart(range, characterW, -1, -1);
3166 test_range_text(range, " ");
3167 test_range_move(range, wordW, 1, 1);
3168 test_range_moveend(range, characterW, 3, 3);
3169 test_range_text(range, "def");
3170 test_range_put_text(range, "xyz");
3171 test_range_moveend(range, characterW, 1, 1);
3172 test_range_move(range, wordW, 1, 1);
3173 test_range_moveend(range, characterW, 2, 2);
3174 test_range_text(range, "ab");
3176 IHTMLTxtRange_Release(range);
3179 static void test_txtrange2(IHTMLDocument2 *doc)
3181 IHTMLTxtRange *range;
3183 range = test_create_body_range(doc);
3185 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3186 test_range_move(range, characterW, 5, 5);
3187 test_range_moveend(range, characterW, 1, 1);
3188 test_range_text(range, "2");
3189 test_range_move(range, characterW, -3, -3);
3190 test_range_moveend(range, characterW, 3, 3);
3191 test_range_text(range, "c\r\n\r\n1");
3192 test_range_collapse(range, VARIANT_FALSE);
3193 test_range_moveend(range, characterW, 4, 4);
3194 test_range_text(range, "23");
3195 test_range_moveend(range, characterW, 1, 1);
3196 test_range_text(range, "23\r\n\r\n\r\nd");
3197 test_range_moveend(range, characterW, -1, -1);
3198 test_range_text(range, "23");
3199 test_range_moveend(range, characterW, -1, -1);
3200 test_range_text(range, "23");
3201 test_range_moveend(range, characterW, -2, -2);
3202 test_range_text(range, "2");
3204 IHTMLTxtRange_Release(range);
3207 static void test_compatmode(IHTMLDocument2 *doc)
3209 IHTMLDocument5 *doc5;
3210 BSTR mode;
3211 HRESULT hres;
3213 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3214 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3215 if(FAILED(hres))
3216 return;
3218 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3219 IHTMLDocument5_Release(doc5);
3220 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3221 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3222 SysFreeString(mode);
3225 static void test_location(IHTMLDocument2 *doc)
3227 IHTMLLocation *location, *location2;
3228 IHTMLWindow2 *window;
3229 BSTR str;
3230 ULONG ref;
3231 HRESULT hres;
3233 hres = IHTMLDocument2_get_location(doc, &location);
3234 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3236 hres = IHTMLDocument2_get_location(doc, &location2);
3237 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3239 ok(location == location2, "location != location2\n");
3240 IHTMLLocation_Release(location2);
3242 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3243 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3245 hres = IHTMLWindow2_get_location(window, &location2);
3246 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3247 ok(location == location2, "location != location2\n");
3248 IHTMLLocation_Release(location2);
3250 test_ifaces((IUnknown*)location, location_iids);
3251 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3253 hres = IHTMLLocation_get_pathname(location, &str);
3254 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3255 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3257 hres = IHTMLLocation_get_href(location, NULL);
3258 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3260 hres = IHTMLLocation_get_href(location, &str);
3261 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3262 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3264 ref = IHTMLLocation_Release(location);
3265 ok(!ref, "location chould be destroyed here\n");
3268 static void test_navigator(IHTMLDocument2 *doc)
3270 IHTMLWindow2 *window;
3271 IOmNavigator *navigator, *navigator2;
3272 char buf[512];
3273 DWORD size;
3274 ULONG ref;
3275 BSTR bstr;
3276 HRESULT hres;
3278 static const WCHAR v40[] = {'4','.','0'};
3280 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3281 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3283 hres = IHTMLWindow2_get_navigator(window, &navigator);
3284 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3285 ok(navigator != NULL, "navigator == NULL\n");
3286 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3288 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3289 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3290 ok(navigator != navigator2, "navigator2 != navihgator\n");
3292 IHTMLWindow2_Release(window);
3293 IOmNavigator_Release(navigator2);
3295 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3296 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3297 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3298 SysFreeString(bstr);
3300 bstr = NULL;
3301 hres = IOmNavigator_get_appName(navigator, &bstr);
3302 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3303 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3304 SysFreeString(bstr);
3306 bstr = NULL;
3307 hres = IOmNavigator_get_platform(navigator, &bstr);
3308 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3309 #ifdef _WIN64
3310 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3311 #else
3312 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3313 #endif
3314 SysFreeString(bstr);
3316 bstr = NULL;
3317 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3318 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3319 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3320 SysFreeString(bstr);
3322 hres = IOmNavigator_toString(navigator, NULL);
3323 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3325 bstr = NULL;
3326 hres = IOmNavigator_toString(navigator, &bstr);
3327 ok(hres == S_OK, "toString failed: %08x\n", hres);
3328 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3329 SysFreeString(bstr);
3331 size = sizeof(buf);
3332 hres = ObtainUserAgentString(0, buf, &size);
3333 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3335 bstr = NULL;
3336 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3337 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3338 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3339 SysFreeString(bstr);
3341 if(!strncmp(buf, "Mozilla/", 8)) {
3342 bstr = NULL;
3343 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3344 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3345 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
3346 SysFreeString(bstr);
3347 }else {
3348 skip("nonstandard user agent\n");
3351 ref = IOmNavigator_Release(navigator);
3352 ok(!ref, "navigator should be destroyed here\n");
3355 static void test_screen(IHTMLWindow2 *window)
3357 IHTMLScreen *screen, *screen2;
3358 IDispatchEx *dispex;
3359 LONG l, exl;
3360 HDC hdc;
3361 HRESULT hres;
3363 screen = NULL;
3364 hres = IHTMLWindow2_get_screen(window, &screen);
3365 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3366 ok(screen != NULL, "screen == NULL\n");
3368 screen2 = NULL;
3369 hres = IHTMLWindow2_get_screen(window, &screen2);
3370 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3371 ok(screen2 != NULL, "screen == NULL\n");
3372 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3373 IHTMLScreen_Release(screen2);
3375 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3376 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3377 if(SUCCEEDED(hres)) {
3378 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3379 IDispatchEx_Release(dispex);
3382 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
3384 exl = GetDeviceCaps(hdc, HORZRES);
3385 l = 0xdeadbeef;
3386 hres = IHTMLScreen_get_width(screen, &l);
3387 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3388 ok(l == exl, "width = %d, expected %d\n", l, exl);
3390 exl = GetDeviceCaps(hdc, VERTRES);
3391 l = 0xdeadbeef;
3392 hres = IHTMLScreen_get_height(screen, &l);
3393 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3394 ok(l == exl, "height = %d, expected %d\n", l, exl);
3396 exl = GetDeviceCaps(hdc, BITSPIXEL);
3397 l = 0xdeadbeef;
3398 hres = IHTMLScreen_get_colorDepth(screen, &l);
3399 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3400 ok(l == exl, "height = %d, expected %d\n", l, exl);
3402 DeleteObject(hdc);
3404 IHTMLScreen_Release(screen);
3407 static void test_current_style(IHTMLCurrentStyle *current_style)
3409 BSTR str;
3410 HRESULT hres;
3411 VARIANT v;
3413 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3414 test_ifaces((IUnknown*)current_style, cstyle_iids);
3416 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3417 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3418 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3419 SysFreeString(str);
3421 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3422 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3423 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3424 SysFreeString(str);
3426 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3427 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3428 SysFreeString(str);
3430 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3431 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3432 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3433 SysFreeString(str);
3435 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3436 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3437 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3438 SysFreeString(str);
3440 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3441 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3442 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3443 SysFreeString(str);
3445 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3446 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3447 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3448 SysFreeString(str);
3450 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3451 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3452 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3453 SysFreeString(str);
3455 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3456 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3457 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3458 SysFreeString(str);
3460 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3461 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3462 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3463 SysFreeString(str);
3465 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3466 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3467 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3468 SysFreeString(str);
3470 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3471 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3472 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3473 SysFreeString(str);
3475 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3476 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3477 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3478 SysFreeString(str);
3480 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3481 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3482 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3483 SysFreeString(str);
3485 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3486 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3487 SysFreeString(str);
3489 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3490 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3491 SysFreeString(str);
3493 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3494 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3495 SysFreeString(str);
3497 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3498 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3499 SysFreeString(str);
3501 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3502 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3503 SysFreeString(str);
3505 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3506 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3507 SysFreeString(str);
3509 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3510 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3511 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3512 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3513 VariantClear(&v);
3515 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3516 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3517 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3518 VariantClear(&v);
3520 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3521 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3522 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3523 VariantClear(&v);
3525 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3526 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3527 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3528 VariantClear(&v);
3530 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3531 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3532 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3533 VariantClear(&v);
3535 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3536 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3537 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3538 VariantClear(&v);
3540 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3541 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3542 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3543 VariantClear(&v);
3545 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3546 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3547 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3548 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3549 VariantClear(&v);
3551 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3552 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3553 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3554 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3555 VariantClear(&v);
3557 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3558 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3559 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3560 VariantClear(&v);
3562 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3563 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3564 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3565 VariantClear(&v);
3567 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3568 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3569 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3570 VariantClear(&v);
3572 V_BSTR(&v) = NULL;
3573 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3574 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3575 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3576 VariantClear(&v);
3578 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3579 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3580 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3581 VariantClear(&v);
3583 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3584 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3585 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3586 VariantClear(&v);
3588 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3589 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3590 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3591 VariantClear(&v);
3593 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3594 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3595 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3596 VariantClear(&v);
3598 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3599 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3600 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3601 VariantClear(&v);
3603 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3604 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3605 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3606 VariantClear(&v);
3608 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3609 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3610 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3611 VariantClear(&v);
3613 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3614 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3615 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3616 VariantClear(&v);
3618 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3619 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3620 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3621 VariantClear(&v);
3623 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3624 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3625 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3626 VariantClear(&v);
3628 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3629 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3630 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3631 VariantClear(&v);
3633 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3634 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3635 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3636 VariantClear(&v);
3638 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3639 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3640 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3641 VariantClear(&v);
3643 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3644 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3645 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3646 VariantClear(&v);
3648 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3649 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3650 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3651 VariantClear(&v);
3653 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3654 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3655 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3656 VariantClear(&v);
3658 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3659 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3660 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3661 VariantClear(&v);
3663 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3664 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3665 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3666 VariantClear(&v);
3669 static void test_style2(IHTMLStyle2 *style2)
3671 VARIANT v;
3672 BSTR str;
3673 HRESULT hres;
3675 str = (void*)0xdeadbeef;
3676 hres = IHTMLStyle2_get_position(style2, &str);
3677 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3678 ok(!str, "str != NULL\n");
3680 str = a2bstr("absolute");
3681 hres = IHTMLStyle2_put_position(style2, str);
3682 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3683 SysFreeString(str);
3685 str = NULL;
3686 hres = IHTMLStyle2_get_position(style2, &str);
3687 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3688 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3689 SysFreeString(str);
3691 /* Test right */
3692 V_VT(&v) = VT_EMPTY;
3693 hres = IHTMLStyle2_get_right(style2, &v);
3694 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3695 ok(V_VT(&v) == VT_BSTR, "V_VT(right)=%d\n", V_VT(&v));
3696 ok(!V_BSTR(&v), "V_BSTR(right) != NULL\n");
3697 VariantClear(&v);
3699 V_VT(&v) = VT_BSTR;
3700 V_BSTR(&v) = a2bstr("3px");
3701 hres = IHTMLStyle2_put_right(style2, v);
3702 ok(hres == S_OK, "put_right failed: %08x\n", hres);
3703 VariantClear(&v);
3705 V_VT(&v) = VT_EMPTY;
3706 hres = IHTMLStyle2_get_right(style2, &v);
3707 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3708 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3709 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3710 VariantClear(&v);
3713 static void test_style3(IHTMLStyle3 *style3)
3715 BSTR str;
3716 HRESULT hres;
3718 str = (void*)0xdeadbeef;
3719 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3720 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3721 ok(!str, "str != NULL\n");
3723 str = a2bstr("break-word");
3724 hres = IHTMLStyle3_put_wordWrap(style3, str);
3725 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3726 SysFreeString(str);
3728 str = NULL;
3729 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3730 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3731 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3732 SysFreeString(str);
3735 static void test_style4(IHTMLStyle4 *style4)
3737 HRESULT hres;
3738 VARIANT v;
3739 VARIANT vdefault;
3741 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3742 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3744 V_VT(&v) = VT_BSTR;
3745 V_BSTR(&v) = a2bstr("10px");
3746 hres = IHTMLStyle4_put_minHeight(style4, v);
3747 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3748 VariantClear(&v);
3750 hres = IHTMLStyle4_get_minHeight(style4, &v);
3751 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3752 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3753 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3755 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3756 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3757 VariantClear(&vdefault);
3760 static void test_default_style(IHTMLStyle *style)
3762 IHTMLStyle2 *style2;
3763 IHTMLStyle3 *style3;
3764 IHTMLStyle4 *style4;
3765 VARIANT_BOOL b;
3766 VARIANT v;
3767 BSTR str;
3768 HRESULT hres;
3769 float f;
3770 BSTR sOverflowDefault;
3771 BSTR sDefault;
3772 VARIANT vDefault;
3774 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3775 test_ifaces((IUnknown*)style, style_iids);
3777 test_style_csstext(style, NULL);
3779 hres = IHTMLStyle_get_position(style, &str);
3780 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3781 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3783 V_VT(&v) = VT_NULL;
3784 hres = IHTMLStyle_get_marginRight(style, &v);
3785 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3786 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3787 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3789 V_VT(&v) = VT_NULL;
3790 hres = IHTMLStyle_get_marginLeft(style, &v);
3791 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3792 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3793 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3795 str = (void*)0xdeadbeef;
3796 hres = IHTMLStyle_get_fontFamily(style, &str);
3797 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3798 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3800 str = (void*)0xdeadbeef;
3801 hres = IHTMLStyle_get_fontWeight(style, &str);
3802 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3803 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3805 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3806 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3808 str = a2bstr("test");
3809 hres = IHTMLStyle_put_fontWeight(style, str);
3810 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3811 SysFreeString(str);
3813 str = a2bstr("bold");
3814 hres = IHTMLStyle_put_fontWeight(style, str);
3815 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3816 SysFreeString(str);
3818 str = a2bstr("bolder");
3819 hres = IHTMLStyle_put_fontWeight(style, str);
3820 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3821 SysFreeString(str);
3823 str = a2bstr("lighter");
3824 hres = IHTMLStyle_put_fontWeight(style, str);
3825 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3826 SysFreeString(str);
3828 str = a2bstr("100");
3829 hres = IHTMLStyle_put_fontWeight(style, str);
3830 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3831 SysFreeString(str);
3833 str = a2bstr("200");
3834 hres = IHTMLStyle_put_fontWeight(style, str);
3835 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3836 SysFreeString(str);
3838 str = a2bstr("300");
3839 hres = IHTMLStyle_put_fontWeight(style, str);
3840 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3841 SysFreeString(str);
3843 str = a2bstr("400");
3844 hres = IHTMLStyle_put_fontWeight(style, str);
3845 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3846 SysFreeString(str);
3848 str = a2bstr("500");
3849 hres = IHTMLStyle_put_fontWeight(style, str);
3850 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3851 SysFreeString(str);
3853 str = a2bstr("600");
3854 hres = IHTMLStyle_put_fontWeight(style, str);
3855 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3856 SysFreeString(str);
3858 str = a2bstr("700");
3859 hres = IHTMLStyle_put_fontWeight(style, str);
3860 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3861 SysFreeString(str);
3863 str = a2bstr("800");
3864 hres = IHTMLStyle_put_fontWeight(style, str);
3865 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3866 SysFreeString(str);
3868 str = a2bstr("900");
3869 hres = IHTMLStyle_put_fontWeight(style, str);
3870 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3871 SysFreeString(str);
3873 hres = IHTMLStyle_get_fontWeight(style, &str);
3874 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3875 ok(!strcmp_wa(str, "900"), "str != style900\n");
3876 SysFreeString(str);
3878 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3879 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3880 SysFreeString(sDefault);
3882 /* font Variant */
3883 hres = IHTMLStyle_get_fontVariant(style, NULL);
3884 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3886 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3887 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3889 str = a2bstr("test");
3890 hres = IHTMLStyle_put_fontVariant(style, str);
3891 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3892 SysFreeString(str);
3894 str = a2bstr("small-caps");
3895 hres = IHTMLStyle_put_fontVariant(style, str);
3896 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3897 SysFreeString(str);
3899 str = a2bstr("normal");
3900 hres = IHTMLStyle_put_fontVariant(style, str);
3901 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3902 SysFreeString(str);
3904 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3905 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3906 SysFreeString(sDefault);
3908 str = (void*)0xdeadbeef;
3909 hres = IHTMLStyle_get_display(style, &str);
3910 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3911 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3913 str = (void*)0xdeadbeef;
3914 hres = IHTMLStyle_get_visibility(style, &str);
3915 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3916 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3918 V_VT(&v) = VT_NULL;
3919 hres = IHTMLStyle_get_fontSize(style, &v);
3920 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3921 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3922 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3924 V_VT(&v) = VT_NULL;
3925 hres = IHTMLStyle_get_color(style, &v);
3926 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3927 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3928 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3930 b = 0xfefe;
3931 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3932 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3933 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3935 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3936 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3937 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3939 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3940 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3941 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3943 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3944 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3946 b = 0xfefe;
3947 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3948 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3949 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3951 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3952 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3953 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3955 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3956 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3957 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3959 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3960 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3962 b = 0xfefe;
3963 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3964 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3965 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3967 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3968 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3969 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3971 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3972 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3973 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3975 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3976 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3978 b = 0xfefe;
3979 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3980 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3981 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3983 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3984 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3985 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3987 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3988 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3989 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3991 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3992 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3994 b = 0xfefe;
3995 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3996 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3997 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3999 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
4000 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
4001 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4003 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4004 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4005 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
4007 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
4008 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
4010 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
4011 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4013 str = a2bstr("invalid");
4014 hres = IHTMLStyle_put_textDecoration(style, str);
4015 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
4016 SysFreeString(str);
4018 str = a2bstr("none");
4019 hres = IHTMLStyle_put_textDecoration(style, str);
4020 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4021 SysFreeString(str);
4023 str = a2bstr("underline");
4024 hres = IHTMLStyle_put_textDecoration(style, str);
4025 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4026 SysFreeString(str);
4028 str = a2bstr("overline");
4029 hres = IHTMLStyle_put_textDecoration(style, str);
4030 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4031 SysFreeString(str);
4033 str = a2bstr("line-through");
4034 hres = IHTMLStyle_put_textDecoration(style, str);
4035 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4036 SysFreeString(str);
4038 str = a2bstr("blink");
4039 hres = IHTMLStyle_put_textDecoration(style, str);
4040 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4041 SysFreeString(str);
4043 hres = IHTMLStyle_get_textDecoration(style, &str);
4044 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4045 ok(!strcmp_wa(str, "blink"), "str != blink\n");
4046 SysFreeString(str);
4048 hres = IHTMLStyle_put_textDecoration(style, sDefault);
4049 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4050 SysFreeString(sDefault);
4052 hres = IHTMLStyle_get_posWidth(style, NULL);
4053 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
4055 hres = IHTMLStyle_get_posWidth(style, &f);
4056 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4057 ok(f == 0.0f, "f = %f\n", f);
4059 V_VT(&v) = VT_EMPTY;
4060 hres = IHTMLStyle_get_width(style, &v);
4061 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4062 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4063 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
4065 hres = IHTMLStyle_put_posWidth(style, 2.2);
4066 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
4068 hres = IHTMLStyle_get_posWidth(style, &f);
4069 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4070 ok(f == 2.0f ||
4071 f == 2.2f, /* IE8 */
4072 "f = %f\n", f);
4074 V_VT(&v) = VT_BSTR;
4075 V_BSTR(&v) = a2bstr("auto");
4076 hres = IHTMLStyle_put_width(style, v);
4077 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4078 VariantClear(&v);
4080 V_VT(&v) = VT_EMPTY;
4081 hres = IHTMLStyle_get_width(style, &v);
4082 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4083 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4084 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4085 VariantClear(&v);
4087 V_VT(&v) = VT_I4;
4088 V_I4(&v) = 100;
4089 hres = IHTMLStyle_put_width(style, v);
4090 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4092 V_VT(&v) = VT_EMPTY;
4093 hres = IHTMLStyle_get_width(style, &v);
4094 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4095 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4096 ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4097 VariantClear(&v);
4099 /* margin tests */
4100 str = (void*)0xdeadbeef;
4101 hres = IHTMLStyle_get_margin(style, &str);
4102 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4103 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
4105 str = a2bstr("1");
4106 hres = IHTMLStyle_put_margin(style, str);
4107 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4108 SysFreeString(str);
4110 hres = IHTMLStyle_get_margin(style, &str);
4111 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4112 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
4114 hres = IHTMLStyle_put_margin(style, NULL);
4115 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4117 str = (void*)0xdeadbeef;
4118 hres = IHTMLStyle_get_marginTop(style, &v);
4119 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4120 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4121 ok(!V_BSTR(&v), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4123 V_VT(&v) = VT_BSTR;
4124 V_BSTR(&v) = a2bstr("6px");
4125 hres = IHTMLStyle_put_marginTop(style, v);
4126 SysFreeString(V_BSTR(&v));
4127 ok(hres == S_OK, "put_marginTop failed: %08x\n", hres);
4129 str = (void*)0xdeadbeef;
4130 hres = IHTMLStyle_get_marginTop(style, &v);
4131 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4132 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4133 ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4135 str = NULL;
4136 hres = IHTMLStyle_get_border(style, &str);
4137 ok(hres == S_OK, "get_border failed: %08x\n", hres);
4138 ok(!str || !*str, "str is not empty\n");
4139 SysFreeString(str);
4141 str = a2bstr("1px");
4142 hres = IHTMLStyle_put_border(style, str);
4143 ok(hres == S_OK, "put_border failed: %08x\n", hres);
4144 SysFreeString(str);
4146 V_VT(&v) = VT_EMPTY;
4147 hres = IHTMLStyle_get_left(style, &v);
4148 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4149 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4150 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4151 VariantClear(&v);
4153 /* Test posLeft */
4154 hres = IHTMLStyle_get_posLeft(style, NULL);
4155 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
4157 f = 1.0f;
4158 hres = IHTMLStyle_get_posLeft(style, &f);
4159 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4160 ok(f == 0.0, "expected 0.0 got %f\n", f);
4162 hres = IHTMLStyle_put_posLeft(style, 4.9f);
4163 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
4165 hres = IHTMLStyle_get_posLeft(style, &f);
4166 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4167 ok(f == 4.0 ||
4168 f == 4.9f, /* IE8 */
4169 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4171 /* Ensure left is updated correctly. */
4172 V_VT(&v) = VT_EMPTY;
4173 hres = IHTMLStyle_get_left(style, &v);
4174 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4175 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4176 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
4177 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
4178 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4179 VariantClear(&v);
4181 /* Test left */
4182 V_VT(&v) = VT_BSTR;
4183 V_BSTR(&v) = a2bstr("3px");
4184 hres = IHTMLStyle_put_left(style, v);
4185 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4186 VariantClear(&v);
4188 hres = IHTMLStyle_get_posLeft(style, &f);
4189 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4190 ok(f == 3.0, "expected 3.0 got %f\n", f);
4192 V_VT(&v) = VT_EMPTY;
4193 hres = IHTMLStyle_get_left(style, &v);
4194 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4195 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4196 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4197 VariantClear(&v);
4199 V_VT(&v) = VT_NULL;
4200 hres = IHTMLStyle_put_left(style, v);
4201 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4203 V_VT(&v) = VT_EMPTY;
4204 hres = IHTMLStyle_get_left(style, &v);
4205 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4206 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4207 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4208 VariantClear(&v);
4210 V_VT(&v) = VT_EMPTY;
4211 hres = IHTMLStyle_get_top(style, &v);
4212 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4213 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4214 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4215 VariantClear(&v);
4217 /* Test posTop */
4218 hres = IHTMLStyle_get_posTop(style, NULL);
4219 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
4221 f = 1.0f;
4222 hres = IHTMLStyle_get_posTop(style, &f);
4223 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4224 ok(f == 0.0, "expected 0.0 got %f\n", f);
4226 hres = IHTMLStyle_put_posTop(style, 4.9f);
4227 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
4229 hres = IHTMLStyle_get_posTop(style, &f);
4230 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4231 ok(f == 4.0 ||
4232 f == 4.9f, /* IE8 */
4233 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4235 V_VT(&v) = VT_BSTR;
4236 V_BSTR(&v) = a2bstr("3px");
4237 hres = IHTMLStyle_put_top(style, v);
4238 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4239 VariantClear(&v);
4241 V_VT(&v) = VT_EMPTY;
4242 hres = IHTMLStyle_get_top(style, &v);
4243 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4244 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4245 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4246 VariantClear(&v);
4248 hres = IHTMLStyle_get_posTop(style, &f);
4249 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4250 ok(f == 3.0, "expected 3.0 got %f\n", f);
4252 V_VT(&v) = VT_NULL;
4253 hres = IHTMLStyle_put_top(style, v);
4254 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4256 V_VT(&v) = VT_EMPTY;
4257 hres = IHTMLStyle_get_top(style, &v);
4258 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4259 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4260 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4261 VariantClear(&v);
4263 /* Test posHeight */
4264 hres = IHTMLStyle_get_posHeight(style, NULL);
4265 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
4267 V_VT(&v) = VT_EMPTY;
4268 hres = IHTMLStyle_get_height(style, &v);
4269 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4270 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4271 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4272 VariantClear(&v);
4274 f = 1.0f;
4275 hres = IHTMLStyle_get_posHeight(style, &f);
4276 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4277 ok(f == 0.0, "expected 0.0 got %f\n", f);
4279 hres = IHTMLStyle_put_posHeight(style, 4.9f);
4280 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
4282 hres = IHTMLStyle_get_posHeight(style, &f);
4283 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4284 ok(f == 4.0 ||
4285 f == 4.9f, /* IE8 */
4286 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4288 V_VT(&v) = VT_BSTR;
4289 V_BSTR(&v) = a2bstr("64px");
4290 hres = IHTMLStyle_put_height(style, v);
4291 ok(hres == S_OK, "put_height failed: %08x\n", hres);
4292 VariantClear(&v);
4294 V_VT(&v) = VT_EMPTY;
4295 hres = IHTMLStyle_get_height(style, &v);
4296 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4297 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4298 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4299 VariantClear(&v);
4301 hres = IHTMLStyle_get_posHeight(style, &f);
4302 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4303 ok(f == 64.0, "expected 64.0 got %f\n", f);
4305 str = (void*)0xdeadbeef;
4306 hres = IHTMLStyle_get_cursor(style, &str);
4307 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4308 ok(!str, "get_cursor != NULL\n");
4309 SysFreeString(str);
4311 str = a2bstr("default");
4312 hres = IHTMLStyle_put_cursor(style, str);
4313 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
4314 SysFreeString(str);
4316 str = NULL;
4317 hres = IHTMLStyle_get_cursor(style, &str);
4318 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4319 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4320 SysFreeString(str);
4322 V_VT(&v) = VT_EMPTY;
4323 hres = IHTMLStyle_get_verticalAlign(style, &v);
4324 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
4325 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4326 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4327 VariantClear(&v);
4329 V_VT(&v) = VT_BSTR;
4330 V_BSTR(&v) = a2bstr("middle");
4331 hres = IHTMLStyle_put_verticalAlign(style, v);
4332 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
4333 VariantClear(&v);
4335 V_VT(&v) = VT_EMPTY;
4336 hres = IHTMLStyle_get_verticalAlign(style, &v);
4337 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4338 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4339 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4340 VariantClear(&v);
4342 str = (void*)0xdeadbeef;
4343 hres = IHTMLStyle_get_textAlign(style, &str);
4344 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4345 ok(!str, "textAlign != NULL\n");
4347 str = a2bstr("center");
4348 hres = IHTMLStyle_put_textAlign(style, str);
4349 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
4350 SysFreeString(str);
4352 str = NULL;
4353 hres = IHTMLStyle_get_textAlign(style, &str);
4354 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4355 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4356 SysFreeString(str);
4358 str = (void*)0xdeadbeef;
4359 hres = IHTMLStyle_get_filter(style, &str);
4360 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4361 ok(!str, "filter != NULL\n");
4363 str = a2bstr("alpha(opacity=100)");
4364 hres = IHTMLStyle_put_filter(style, str);
4365 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
4366 SysFreeString(str);
4368 V_VT(&v) = VT_EMPTY;
4369 hres = IHTMLStyle_get_zIndex(style, &v);
4370 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4371 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4372 ok(!V_I4(&v), "V_I4(v) != 0\n");
4373 VariantClear(&v);
4375 V_VT(&v) = VT_BSTR;
4376 V_BSTR(&v) = a2bstr("1");
4377 hres = IHTMLStyle_put_zIndex(style, v);
4378 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4379 VariantClear(&v);
4381 V_VT(&v) = VT_EMPTY;
4382 hres = IHTMLStyle_get_zIndex(style, &v);
4383 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4384 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4385 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4386 VariantClear(&v);
4388 /* fontStyle */
4389 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4390 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4392 str = a2bstr("test");
4393 hres = IHTMLStyle_put_fontStyle(style, str);
4394 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4395 SysFreeString(str);
4397 str = a2bstr("italic");
4398 hres = IHTMLStyle_put_fontStyle(style, str);
4399 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4400 SysFreeString(str);
4402 str = a2bstr("oblique");
4403 hres = IHTMLStyle_put_fontStyle(style, str);
4404 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4405 SysFreeString(str);
4407 str = a2bstr("normal");
4408 hres = IHTMLStyle_put_fontStyle(style, str);
4409 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4410 SysFreeString(str);
4412 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4413 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4414 SysFreeString(sDefault);
4416 /* overflow */
4417 hres = IHTMLStyle_get_overflow(style, NULL);
4418 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4420 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4421 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4423 str = a2bstr("test");
4424 hres = IHTMLStyle_put_overflow(style, str);
4425 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4426 SysFreeString(str);
4428 str = a2bstr("visible");
4429 hres = IHTMLStyle_put_overflow(style, str);
4430 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4431 SysFreeString(str);
4433 str = a2bstr("scroll");
4434 hres = IHTMLStyle_put_overflow(style, str);
4435 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4436 SysFreeString(str);
4438 str = a2bstr("hidden");
4439 hres = IHTMLStyle_put_overflow(style, str);
4440 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4441 SysFreeString(str);
4443 str = a2bstr("auto");
4444 hres = IHTMLStyle_put_overflow(style, str);
4445 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4446 SysFreeString(str);
4448 hres = IHTMLStyle_get_overflow(style, &str);
4449 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4450 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4451 SysFreeString(str);
4453 str = a2bstr("");
4454 hres = IHTMLStyle_put_overflow(style, str);
4455 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4456 SysFreeString(str);
4458 hres = IHTMLStyle_get_overflow(style, &str);
4459 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4460 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4461 SysFreeString(str);
4463 /* restore overflow default */
4464 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4465 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4466 SysFreeString(sOverflowDefault);
4468 /* Attribute Tests*/
4469 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4470 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4472 str = a2bstr("position");
4473 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4474 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4476 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4477 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4478 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4479 VariantClear(&v);
4481 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4482 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4484 V_VT(&v) = VT_BSTR;
4485 V_BSTR(&v) = a2bstr("absolute");
4486 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4487 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4488 VariantClear(&v);
4490 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4491 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4492 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4493 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4494 VariantClear(&v);
4496 V_VT(&v) = VT_BSTR;
4497 V_BSTR(&v) = NULL;
4498 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4499 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4500 VariantClear(&v);
4502 SysFreeString(str);
4504 str = a2bstr("borderLeftStyle");
4505 test_border_styles(style, str);
4506 SysFreeString(str);
4508 str = a2bstr("borderbottomstyle");
4509 test_border_styles(style, str);
4510 SysFreeString(str);
4512 str = a2bstr("borderrightstyle");
4513 test_border_styles(style, str);
4514 SysFreeString(str);
4516 str = a2bstr("bordertopstyle");
4517 test_border_styles(style, str);
4518 SysFreeString(str);
4520 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4521 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4523 str = a2bstr("none dotted dashed solid");
4524 hres = IHTMLStyle_put_borderStyle(style, str);
4525 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4526 SysFreeString(str);
4528 str = a2bstr("none dotted dashed solid");
4529 hres = IHTMLStyle_get_borderStyle(style, &str);
4530 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4531 ok(!strcmp_wa(str, "none dotted dashed solid"),
4532 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4533 SysFreeString(str);
4535 str = a2bstr("double groove ridge inset");
4536 hres = IHTMLStyle_put_borderStyle(style, str);
4537 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4538 SysFreeString(str);
4540 str = a2bstr("window-inset outset ridge inset");
4541 hres = IHTMLStyle_put_borderStyle(style, str);
4542 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4543 SysFreeString(str);
4545 str = a2bstr("window-inset");
4546 hres = IHTMLStyle_put_borderStyle(style, str);
4547 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4548 SysFreeString(str);
4550 str = a2bstr("none none none none none");
4551 hres = IHTMLStyle_put_borderStyle(style, str);
4552 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4553 SysFreeString(str);
4555 str = a2bstr("invalid none none none");
4556 hres = IHTMLStyle_put_borderStyle(style, str);
4557 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4558 SysFreeString(str);
4560 str = a2bstr("none invalid none none");
4561 hres = IHTMLStyle_put_borderStyle(style, str);
4562 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4563 SysFreeString(str);
4565 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4566 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4567 SysFreeString(sDefault);
4569 /* backgoundColor */
4570 hres = IHTMLStyle_get_backgroundColor(style, &v);
4571 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4572 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4573 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4574 VariantClear(&v);
4576 /* PaddingLeft */
4577 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4578 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4580 V_VT(&v) = VT_BSTR;
4581 V_BSTR(&v) = a2bstr("10");
4582 hres = IHTMLStyle_put_paddingLeft(style, v);
4583 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4584 VariantClear(&v);
4586 hres = IHTMLStyle_get_paddingLeft(style, &v);
4587 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4588 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4590 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4591 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4593 /* BackgroundRepeat */
4594 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4595 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4597 str = a2bstr("invalid");
4598 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4599 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4600 SysFreeString(str);
4602 str = a2bstr("repeat");
4603 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4604 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4605 SysFreeString(str);
4607 str = a2bstr("no-repeat");
4608 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4609 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4610 SysFreeString(str);
4612 str = a2bstr("repeat-x");
4613 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4614 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4615 SysFreeString(str);
4617 str = a2bstr("repeat-y");
4618 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4619 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4620 SysFreeString(str);
4622 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4623 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4624 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4625 SysFreeString(str);
4627 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4628 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4629 SysFreeString(sDefault);
4631 /* BorderColor */
4632 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4633 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4635 str = a2bstr("red green red blue");
4636 hres = IHTMLStyle_put_borderColor(style, str);
4637 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4638 SysFreeString(str);
4640 hres = IHTMLStyle_get_borderColor(style, &str);
4641 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4642 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4643 SysFreeString(str);
4645 hres = IHTMLStyle_put_borderColor(style, sDefault);
4646 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4647 SysFreeString(sDefault);
4649 /* BorderRight */
4650 hres = IHTMLStyle_get_borderRight(style, &sDefault);
4651 ok(hres == S_OK, "get_borderRight failed: %08x\n", hres);
4653 str = a2bstr("thick dotted red");
4654 hres = IHTMLStyle_put_borderRight(style, str);
4655 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
4656 SysFreeString(str);
4658 /* IHTMLStyle_get_borderRight appears to have a bug where
4659 it returns the first letter of the color. So we check
4660 each style individually.
4662 V_BSTR(&v) = NULL;
4663 hres = IHTMLStyle_get_borderRightColor(style, &v);
4664 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
4665 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4666 VariantClear(&v);
4668 V_BSTR(&v) = NULL;
4669 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4670 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
4671 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4672 VariantClear(&v);
4674 hres = IHTMLStyle_get_borderRightStyle(style, &str);
4675 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
4676 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4677 SysFreeString(str);
4679 hres = IHTMLStyle_put_borderRight(style, sDefault);
4680 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
4681 SysFreeString(sDefault);
4683 /* BorderTop */
4684 hres = IHTMLStyle_get_borderTop(style, &sDefault);
4685 ok(hres == S_OK, "get_borderTop failed: %08x\n", hres);
4687 str = a2bstr("thick dotted red");
4688 hres = IHTMLStyle_put_borderTop(style, str);
4689 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
4690 SysFreeString(str);
4692 /* IHTMLStyle_get_borderTop appears to have a bug where
4693 it returns the first letter of the color. So we check
4694 each style individually.
4696 V_BSTR(&v) = NULL;
4697 hres = IHTMLStyle_get_borderTopColor(style, &v);
4698 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
4699 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4700 VariantClear(&v);
4702 V_BSTR(&v) = NULL;
4703 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4704 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
4705 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4706 VariantClear(&v);
4708 hres = IHTMLStyle_get_borderTopStyle(style, &str);
4709 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
4710 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4711 SysFreeString(str);
4713 hres = IHTMLStyle_put_borderTop(style, sDefault);
4714 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
4715 SysFreeString(sDefault);
4717 /* BorderBottom */
4718 hres = IHTMLStyle_get_borderBottom(style, &sDefault);
4719 ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres);
4721 str = a2bstr("thick dotted red");
4722 hres = IHTMLStyle_put_borderBottom(style, str);
4723 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
4724 SysFreeString(str);
4726 /* IHTMLStyle_get_borderBottom appears to have a bug where
4727 it returns the first letter of the color. So we check
4728 each style individually.
4730 V_BSTR(&v) = NULL;
4731 hres = IHTMLStyle_get_borderBottomColor(style, &v);
4732 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
4733 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4734 VariantClear(&v);
4736 V_BSTR(&v) = NULL;
4737 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4738 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
4739 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4740 VariantClear(&v);
4742 hres = IHTMLStyle_get_borderBottomStyle(style, &str);
4743 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
4744 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4745 SysFreeString(str);
4747 hres = IHTMLStyle_put_borderBottom(style, sDefault);
4748 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
4749 SysFreeString(sDefault);
4751 /* BorderLeft */
4752 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4753 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4755 str = a2bstr("thick dotted red");
4756 hres = IHTMLStyle_put_borderLeft(style, str);
4757 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4758 SysFreeString(str);
4760 /* IHTMLStyle_get_borderLeft appears to have a bug where
4761 it returns the first letter of the color. So we check
4762 each style individually.
4764 V_BSTR(&v) = NULL;
4765 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4766 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4767 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4768 VariantClear(&v);
4770 V_BSTR(&v) = NULL;
4771 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4772 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4773 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4774 VariantClear(&v);
4776 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4777 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4778 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4779 SysFreeString(str);
4781 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4782 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4783 SysFreeString(sDefault);
4785 /* backgroundPositionX */
4786 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4787 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4789 V_VT(&v) = VT_BSTR;
4790 V_BSTR(&v) = a2bstr("10px");
4791 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4792 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4793 VariantClear(&v);
4795 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4796 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4797 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4798 VariantClear(&v);
4800 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4801 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4802 VariantClear(&vDefault);
4804 /* backgroundPositionY */
4805 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4806 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4808 V_VT(&v) = VT_BSTR;
4809 V_BSTR(&v) = a2bstr("10px");
4810 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4811 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4812 VariantClear(&v);
4814 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4815 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4816 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4817 VariantClear(&v);
4819 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4820 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4821 VariantClear(&vDefault);
4823 /* borderTopWidth */
4824 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4825 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4827 V_VT(&v) = VT_BSTR;
4828 V_BSTR(&v) = a2bstr("10px");
4829 hres = IHTMLStyle_put_borderTopWidth(style, v);
4830 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4831 VariantClear(&v);
4833 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4834 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4835 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4836 VariantClear(&v);
4838 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4839 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4840 VariantClear(&vDefault);
4842 /* borderRightWidth */
4843 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4844 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4846 V_VT(&v) = VT_BSTR;
4847 V_BSTR(&v) = a2bstr("10");
4848 hres = IHTMLStyle_put_borderRightWidth(style, v);
4849 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4850 VariantClear(&v);
4852 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4853 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4854 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4855 VariantClear(&v);
4857 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4858 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4859 VariantClear(&vDefault);
4861 /* borderBottomWidth */
4862 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4863 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4865 V_VT(&v) = VT_BSTR;
4866 V_BSTR(&v) = a2bstr("10");
4867 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4868 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4869 VariantClear(&v);
4871 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4872 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4873 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4874 VariantClear(&v);
4876 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4877 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4878 VariantClear(&vDefault);
4880 /* borderLeftWidth */
4881 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4882 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4884 V_VT(&v) = VT_BSTR;
4885 V_BSTR(&v) = a2bstr("10");
4886 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4887 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4888 VariantClear(&v);
4890 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4891 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4892 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4893 VariantClear(&v);
4895 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4896 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4897 VariantClear(&vDefault);
4899 /* wordSpacing */
4900 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4901 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4903 V_VT(&v) = VT_BSTR;
4904 V_BSTR(&v) = a2bstr("10");
4905 hres = IHTMLStyle_put_wordSpacing(style, v);
4906 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4907 VariantClear(&v);
4909 hres = IHTMLStyle_get_wordSpacing(style, &v);
4910 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4911 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4912 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4913 VariantClear(&v);
4915 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4916 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4917 VariantClear(&vDefault);
4919 /* letterSpacing */
4920 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4921 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4923 V_VT(&v) = VT_BSTR;
4924 V_BSTR(&v) = a2bstr("11");
4925 hres = IHTMLStyle_put_letterSpacing(style, v);
4926 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4927 VariantClear(&v);
4929 hres = IHTMLStyle_get_letterSpacing(style, &v);
4930 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4931 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4932 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4933 VariantClear(&v);
4935 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4936 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4937 VariantClear(&vDefault);
4939 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4940 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4941 if(SUCCEEDED(hres)) {
4942 test_style2(style2);
4943 IHTMLStyle2_Release(style2);
4946 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4947 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4948 if(SUCCEEDED(hres)) {
4949 test_style3(style3);
4950 IHTMLStyle3_Release(style3);
4953 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4954 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4955 if(SUCCEEDED(hres)) {
4956 test_style4(style4);
4957 IHTMLStyle4_Release(style4);
4961 static void test_set_csstext(IHTMLStyle *style)
4963 VARIANT v;
4964 HRESULT hres;
4966 test_style_set_csstext(style, "background-color: black;");
4968 hres = IHTMLStyle_get_backgroundColor(style, &v);
4969 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4970 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4971 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4972 VariantClear(&v);
4975 static void test_default_selection(IHTMLDocument2 *doc)
4977 IHTMLSelectionObject *selection;
4978 IHTMLTxtRange *range;
4979 IDispatch *disp;
4980 BSTR str;
4981 HRESULT hres;
4983 hres = IHTMLDocument2_get_selection(doc, &selection);
4984 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4986 hres = IHTMLSelectionObject_get_type(selection, &str);
4987 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4988 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4989 SysFreeString(str);
4991 hres = IHTMLSelectionObject_createRange(selection, &disp);
4992 IHTMLSelectionObject_Release(selection);
4993 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4995 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4996 IDispatch_Release(disp);
4997 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4999 test_range_text(range, NULL);
5000 IHTMLTxtRange_Release(range);
5003 static void test_doc_elem(IHTMLDocument2 *doc)
5005 IHTMLDocument2 *doc_node, *owner_doc;
5006 IHTMLElement *elem;
5007 IHTMLDocument3 *doc3;
5008 HRESULT hres;
5010 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5011 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
5013 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
5014 IHTMLDocument3_Release(doc3);
5015 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
5017 test_node_name((IUnknown*)elem, "HTML");
5018 test_elem_tag((IUnknown*)elem, "HTML");
5020 doc_node = get_doc_node(doc);
5021 owner_doc = get_owner_doc((IUnknown*)elem);
5022 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
5023 IHTMLDocument2_Release(owner_doc);
5025 owner_doc = get_owner_doc((IUnknown*)doc_node);
5026 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5027 IHTMLDocument2_Release(doc_node);
5029 test_elem_client_rect((IUnknown*)elem);
5031 IHTMLElement_Release(elem);
5034 static void test_default_body(IHTMLBodyElement *body)
5036 LONG l;
5037 BSTR bstr;
5038 HRESULT hres;
5039 VARIANT v;
5041 bstr = (void*)0xdeadbeef;
5042 hres = IHTMLBodyElement_get_background(body, &bstr);
5043 ok(hres == S_OK, "get_background failed: %08x\n", hres);
5044 ok(bstr == NULL, "bstr != NULL\n");
5046 l = elem_get_scroll_height((IUnknown*)body);
5047 ok(l != -1, "scrollHeight == -1\n");
5048 l = elem_get_scroll_width((IUnknown*)body);
5049 ok(l != -1, "scrollWidth == -1\n");
5050 l = elem_get_scroll_top((IUnknown*)body);
5051 ok(!l, "scrollTop = %d\n", l);
5052 elem_get_scroll_left((IUnknown*)body);
5054 /* get_text tests */
5055 hres = IHTMLBodyElement_get_text(body, &v);
5056 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5057 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5058 ok(bstr == NULL, "bstr != NULL\n");
5060 /* get_text - Invalid Text */
5061 V_VT(&v) = VT_BSTR;
5062 V_BSTR(&v) = a2bstr("Invalid");
5063 hres = IHTMLBodyElement_put_text(body, v);
5064 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5065 VariantClear(&v);
5067 V_VT(&v) = VT_NULL;
5068 hres = IHTMLBodyElement_get_text(body, &v);
5069 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5070 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5071 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
5072 VariantClear(&v);
5074 /* get_text - Valid Text */
5075 V_VT(&v) = VT_BSTR;
5076 V_BSTR(&v) = a2bstr("#FF0000");
5077 hres = IHTMLBodyElement_put_text(body, v);
5078 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5079 VariantClear(&v);
5081 V_VT(&v) = VT_NULL;
5082 hres = IHTMLBodyElement_get_text(body, &v);
5083 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5084 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5085 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
5086 VariantClear(&v);
5089 static void test_body_funs(IHTMLBodyElement *body)
5091 VARIANT vbg, vDefaultbg;
5092 HRESULT hres;
5094 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
5095 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5096 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
5097 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
5099 V_VT(&vbg) = VT_BSTR;
5100 V_BSTR(&vbg) = a2bstr("red");
5101 hres = IHTMLBodyElement_put_bgColor(body, vbg);
5102 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5103 VariantClear(&vbg);
5105 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
5106 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5107 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
5108 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
5109 VariantClear(&vbg);
5111 /* Restore Originial */
5112 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
5113 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5114 VariantClear(&vDefaultbg);
5117 static void test_window(IHTMLDocument2 *doc)
5119 IHTMLWindow2 *window, *window2, *self;
5120 IHTMLDocument2 *doc2 = NULL;
5121 IDispatch *disp;
5122 IUnknown *unk;
5123 BSTR str;
5124 HRESULT hres;
5126 hres = IHTMLDocument2_get_parentWindow(doc, &window);
5127 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
5128 test_ifaces((IUnknown*)window, window_iids);
5129 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
5131 hres = IHTMLWindow2_get_document(window, &doc2);
5132 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5133 ok(doc2 != NULL, "doc2 == NULL\n");
5135 test_ifaces((IUnknown*)doc2, doc_node_iids);
5136 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5138 test_ifaces((IUnknown*)doc, doc_obj_iids);
5139 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5141 unk = (void*)0xdeadbeef;
5142 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
5143 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
5144 ok(!unk, "unk = %p\n", unk);
5146 IHTMLDocument_Release(doc2);
5148 hres = IHTMLWindow2_get_window(window, &window2);
5149 ok(hres == S_OK, "get_window failed: %08x\n", hres);
5150 ok(window2 != NULL, "window2 == NULL\n");
5152 hres = IHTMLWindow2_get_self(window, &self);
5153 ok(hres == S_OK, "get_self failed: %08x\n", hres);
5154 ok(window2 != NULL, "self == NULL\n");
5156 ok(self == window2, "self != window2\n");
5158 IHTMLWindow2_Release(window2);
5159 IHTMLWindow2_Release(self);
5161 disp = NULL;
5162 hres = IHTMLDocument2_get_Script(doc, &disp);
5163 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5164 ok(disp == (void*)window, "disp != window\n");
5165 IDispatch_Release(disp);
5167 hres = IHTMLWindow2_toString(window, NULL);
5168 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
5170 str = NULL;
5171 hres = IHTMLWindow2_toString(window, &str);
5172 ok(hres == S_OK, "toString failed: %08x\n", hres);
5173 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
5174 SysFreeString(str);
5176 test_window_name(window, NULL);
5177 set_window_name(window, "test");
5178 test_window_length(window, 0);
5179 test_screen(window);
5181 IHTMLWindow2_Release(window);
5184 static void test_defaults(IHTMLDocument2 *doc)
5186 IHTMLStyleSheetsCollection *stylesheetcol;
5187 IHTMLCurrentStyle *cstyle;
5188 IHTMLBodyElement *body;
5189 IHTMLElement2 *elem2;
5190 IHTMLElement *elem;
5191 IHTMLStyle *style;
5192 LONG l;
5193 HRESULT hres;
5194 IHTMLElementCollection *collection;
5196 hres = IHTMLDocument2_get_body(doc, &elem);
5197 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5199 hres = IHTMLDocument2_get_images(doc, NULL);
5200 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5202 hres = IHTMLDocument2_get_images(doc, &collection);
5203 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5204 if(hres == S_OK)
5206 test_elem_collection((IUnknown*)collection, NULL, 0);
5207 IHTMLElementCollection_Release(collection);
5210 hres = IHTMLDocument2_get_applets(doc, NULL);
5211 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5213 hres = IHTMLDocument2_get_applets(doc, &collection);
5214 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
5215 if(hres == S_OK)
5217 test_elem_collection((IUnknown*)collection, NULL, 0);
5218 IHTMLElementCollection_Release(collection);
5221 hres = IHTMLDocument2_get_links(doc, NULL);
5222 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5224 hres = IHTMLDocument2_get_links(doc, &collection);
5225 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5226 if(hres == S_OK)
5228 test_elem_collection((IUnknown*)collection, NULL, 0);
5229 IHTMLElementCollection_Release(collection);
5232 hres = IHTMLDocument2_get_forms(doc, NULL);
5233 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5235 hres = IHTMLDocument2_get_forms(doc, &collection);
5236 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
5237 if(hres == S_OK)
5239 test_elem_collection((IUnknown*)collection, NULL, 0);
5240 IHTMLElementCollection_Release(collection);
5243 hres = IHTMLDocument2_get_anchors(doc, NULL);
5244 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5246 hres = IHTMLDocument2_get_anchors(doc, &collection);
5247 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5248 if(hres == S_OK)
5250 test_elem_collection((IUnknown*)collection, NULL, 0);
5251 IHTMLElementCollection_Release(collection);
5254 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
5255 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
5256 test_default_body(body);
5257 test_body_funs(body);
5258 IHTMLBodyElement_Release(body);
5260 hres = IHTMLElement_get_style(elem, &style);
5261 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5263 test_default_style(style);
5264 test_window(doc);
5265 test_compatmode(doc);
5266 test_location(doc);
5267 test_navigator(doc);
5269 elem2 = get_elem2_iface((IUnknown*)elem);
5270 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
5271 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
5272 if(SUCCEEDED(hres)) {
5273 test_current_style(cstyle);
5274 IHTMLCurrentStyle_Release(cstyle);
5276 IHTMLElement2_Release(elem2);
5278 IHTMLElement_Release(elem);
5280 test_set_csstext(style);
5281 IHTMLStyle_Release(style);
5283 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
5284 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5286 l = 0xdeadbeef;
5287 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
5288 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5289 ok(l == 0, "length = %d\n", l);
5291 IHTMLStyleSheetsCollection_Release(stylesheetcol);
5293 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
5294 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
5296 test_default_selection(doc);
5297 test_doc_title(doc, "");
5300 static void test_tr_elem(IHTMLElement *elem)
5302 IHTMLElementCollection *col;
5303 IHTMLTableRow *row;
5304 HRESULT hres;
5306 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
5308 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
5309 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
5310 if(FAILED(hres))
5311 return;
5313 col = NULL;
5314 hres = IHTMLTableRow_get_cells(row, &col);
5315 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
5316 ok(col != NULL, "get_cells returned NULL\n");
5318 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
5319 IHTMLElementCollection_Release(col);
5321 IHTMLTable_Release(row);
5324 static void test_table_elem(IHTMLElement *elem)
5326 IHTMLElementCollection *col;
5327 IHTMLTable *table;
5328 IHTMLDOMNode *node;
5329 HRESULT hres;
5331 static const elem_type_t row_types[] = {ET_TR,ET_TR};
5332 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
5334 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
5335 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
5336 if(FAILED(hres))
5337 return;
5339 col = NULL;
5340 hres = IHTMLTable_get_rows(table, &col);
5341 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
5342 ok(col != NULL, "get_ros returned NULL\n");
5344 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
5345 IHTMLElementCollection_Release(col);
5347 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
5349 node = clone_node((IUnknown*)table, VARIANT_TRUE);
5350 test_elem_tag((IUnknown*)node, "TABLE");
5351 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
5352 IHTMLDOMNode_Release(node);
5354 node = clone_node((IUnknown*)table, VARIANT_FALSE);
5355 test_elem_tag((IUnknown*)node, "TABLE");
5356 test_elem_all((IUnknown*)node, NULL, 0);
5357 IHTMLDOMNode_Release(node);
5359 IHTMLTable_Release(table);
5362 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
5364 SAFEARRAYBOUND dim;
5365 SAFEARRAY *sa;
5366 VARIANT *var;
5367 BSTR str;
5368 HRESULT hres;
5370 dim.lLbound = 0;
5371 dim.cElements = 1;
5372 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
5373 SafeArrayAccessData(sa, (void**)&var);
5374 V_VT(var) = VT_BSTR;
5375 V_BSTR(var) = str = a2bstr(text);
5376 SafeArrayUnaccessData(sa);
5378 if(ln)
5379 hres = IHTMLDocument2_writeln(doc, sa);
5380 else
5381 hres = IHTMLDocument2_write(doc, sa);
5382 ok(hres == S_OK, "write failed: %08x\n", hres);
5384 SysFreeString(str);
5385 SafeArrayDestroy(sa);
5388 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
5390 IHTMLDocument2 *window_doc, *elem_doc;
5391 IHTMLFrameElement3 *frame_elem3;
5392 IHTMLWindow2 *content_window;
5393 HRESULT hres;
5395 content_window = get_frame_content_window(frame_elem);
5396 window_doc = get_window_doc(content_window);
5397 IHTMLWindow2_Release(content_window);
5399 elem_doc = get_elem_doc(frame_elem);
5400 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
5402 if(!iframe) {
5403 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
5404 if(SUCCEEDED(hres)) {
5405 IDispatch *disp = NULL;
5407 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
5408 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
5409 ok(disp != NULL, "contentDocument == NULL\n");
5410 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
5412 IDispatch_Release(disp);
5413 IHTMLFrameElement3_Release(frame_elem3);
5414 }else {
5415 win_skip("IHTMLFrameElement3 not supported\n");
5419 IHTMLDocument2_Release(elem_doc);
5420 IHTMLDocument2_Release(window_doc);
5423 static void test_iframe_elem(IHTMLElement *elem)
5425 IHTMLDocument2 *content_doc, *owner_doc;
5426 IHTMLElementCollection *col;
5427 IHTMLWindow2 *content_window;
5428 IDispatch *disp;
5429 VARIANT errv;
5430 BSTR str;
5431 HRESULT hres;
5433 static const elem_type_t all_types[] = {
5434 ET_HTML,
5435 ET_HEAD,
5436 ET_TITLE,
5437 ET_BODY,
5438 ET_BR
5441 test_frame_doc((IUnknown*)elem, TRUE);
5443 content_window = get_frame_content_window((IUnknown*)elem);
5444 test_window_length(content_window, 0);
5446 content_doc = get_window_doc(content_window);
5447 IHTMLWindow2_Release(content_window);
5449 str = a2bstr("text/html");
5450 V_VT(&errv) = VT_ERROR;
5451 disp = NULL;
5452 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
5453 SysFreeString(str);
5454 ok(hres == S_OK, "open failed: %08x\n", hres);
5455 ok(disp != NULL, "disp == NULL\n");
5456 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
5457 IDispatch_Release(disp);
5459 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
5460 doc_write(content_doc, TRUE, "</html>");
5462 hres = IHTMLDocument2_get_all(content_doc, &col);
5463 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5464 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5465 IHTMLElementCollection_Release(col);
5467 hres = IHTMLDocument2_close(content_doc);
5468 ok(hres == S_OK, "close failed: %08x\n", hres);
5470 owner_doc = get_owner_doc((IUnknown*)content_doc);
5471 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5473 IHTMLDocument2_Release(content_doc);
5476 static void test_stylesheet(IDispatch *disp)
5478 IHTMLStyleSheetRulesCollection *col = NULL;
5479 IHTMLStyleSheet *stylesheet;
5480 HRESULT hres;
5482 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
5483 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
5485 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
5486 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
5487 ok(col != NULL, "col == NULL\n");
5489 IHTMLStyleSheetRulesCollection_Release(col);
5490 IHTMLStyleSheet_Release(stylesheet);
5493 static void test_stylesheets(IHTMLDocument2 *doc)
5495 IHTMLStyleSheetsCollection *col = NULL;
5496 VARIANT idx, res;
5497 LONG len = 0;
5498 HRESULT hres;
5500 hres = IHTMLDocument2_get_styleSheets(doc, &col);
5501 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5502 ok(col != NULL, "col == NULL\n");
5504 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
5505 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5506 ok(len == 1, "len=%d\n", len);
5508 VariantInit(&res);
5509 V_VT(&idx) = VT_I4;
5510 V_I4(&idx) = 0;
5512 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5513 ok(hres == S_OK, "item failed: %08x\n", hres);
5514 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
5515 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5516 test_stylesheet(V_DISPATCH(&res));
5517 VariantClear(&res);
5519 V_VT(&res) = VT_I4;
5520 V_VT(&idx) = VT_I4;
5521 V_I4(&idx) = 1;
5523 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5524 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5525 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
5526 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5527 VariantClear(&res);
5529 IHTMLStyleSheetsCollection_Release(col);
5532 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
5534 IDispatchEx *dispex;
5535 IHTMLDOMNode *node;
5536 DISPPARAMS dp = {NULL, NULL, 0, 0};
5537 VARIANT var;
5538 EXCEPINFO ei;
5539 LONG type;
5540 DISPID id;
5541 BSTR bstr;
5542 HRESULT hres;
5544 static const WCHAR w0[] = {'0',0};
5545 static const WCHAR w100[] = {'1','0','0',0};
5547 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
5548 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
5550 bstr = SysAllocString(w0);
5551 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5552 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5553 SysFreeString(bstr);
5555 VariantInit(&var);
5556 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
5557 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
5558 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
5559 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
5560 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
5561 type = get_node_type((IUnknown*)node);
5562 ok(type == 3, "type=%d\n", type);
5563 IHTMLDOMNode_Release(node);
5564 VariantClear(&var);
5566 bstr = SysAllocString(w100);
5567 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5568 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
5569 SysFreeString(bstr);
5571 IDispatchEx_Release(dispex);
5576 static void test_elems(IHTMLDocument2 *doc)
5578 IHTMLElementCollection *col;
5579 IHTMLDOMChildrenCollection *child_col;
5580 IHTMLElement *elem, *elem2, *elem3;
5581 IHTMLDOMNode *node, *node2;
5582 IHTMLWindow2 *window;
5583 IDispatch *disp;
5584 LONG type;
5585 HRESULT hres;
5586 IHTMLElementCollection *collection;
5587 IHTMLDocument3 *doc3;
5588 BSTR str;
5590 static const elem_type_t all_types[] = {
5591 ET_HTML,
5592 ET_HEAD,
5593 ET_TITLE,
5594 ET_STYLE,
5595 ET_BODY,
5596 ET_COMMENT,
5597 ET_A,
5598 ET_INPUT,
5599 ET_SELECT,
5600 ET_OPTION,
5601 ET_OPTION,
5602 ET_TEXTAREA,
5603 ET_TABLE,
5604 ET_TBODY,
5605 ET_TR,
5606 ET_TR,
5607 ET_TD,
5608 ET_TD,
5609 ET_SCRIPT,
5610 ET_TEST,
5611 ET_IMG,
5612 ET_IFRAME,
5613 ET_FORM
5616 static const elem_type_t item_types[] = {
5617 ET_A,
5618 ET_OPTION,
5619 ET_TEXTAREA
5622 hres = IHTMLDocument2_get_all(doc, &col);
5623 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5624 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5625 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5626 IHTMLElementCollection_Release(col);
5628 hres = IHTMLDocument2_get_images(doc, &collection);
5629 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5630 if(hres == S_OK)
5632 static const elem_type_t images_types[] = {ET_IMG};
5633 test_elem_collection((IUnknown*)collection, images_types, 1);
5635 IHTMLElementCollection_Release(collection);
5638 hres = IHTMLDocument2_get_links(doc, &collection);
5639 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5640 if(hres == S_OK)
5642 static const elem_type_t images_types[] = {ET_A};
5643 test_elem_collection((IUnknown*)collection, images_types, 1);
5645 IHTMLElementCollection_Release(collection);
5648 hres = IHTMLDocument2_get_anchors(doc, &collection);
5649 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5650 if(hres == S_OK)
5652 static const elem_type_t anchor_types[] = {ET_A};
5653 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5655 IHTMLElementCollection_Release(collection);
5658 elem = get_doc_elem(doc);
5659 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5660 IHTMLElement_Release(elem);
5662 get_elem_by_id(doc, "xxx", FALSE);
5663 elem = get_doc_elem_by_id(doc, "xxx");
5664 ok(!elem, "elem != NULL\n");
5666 elem = get_doc_elem_by_id(doc, "s");
5667 ok(elem != NULL, "elem == NULL\n");
5668 if(elem) {
5669 test_elem_type((IUnknown*)elem, ET_SELECT);
5670 test_elem_attr(elem, "xxx", NULL);
5671 test_elem_attr(elem, "id", "s");
5672 test_elem_class((IUnknown*)elem, NULL);
5673 test_elem_set_class((IUnknown*)elem, "cl");
5674 test_elem_set_class((IUnknown*)elem, NULL);
5675 test_elem_tabindex((IUnknown*)elem, 0);
5676 test_elem_set_tabindex((IUnknown*)elem, 1);
5677 test_elem_filters((IUnknown*)elem);
5679 node = test_node_get_parent((IUnknown*)elem);
5680 ok(node != NULL, "node == NULL\n");
5681 test_node_name((IUnknown*)node, "BODY");
5682 node2 = test_node_get_parent((IUnknown*)node);
5683 IHTMLDOMNode_Release(node);
5684 ok(node2 != NULL, "node == NULL\n");
5685 test_node_name((IUnknown*)node2, "HTML");
5686 node = test_node_get_parent((IUnknown*)node2);
5687 IHTMLDOMNode_Release(node2);
5688 ok(node != NULL, "node == NULL\n");
5689 if (node)
5691 test_node_name((IUnknown*)node, "#document");
5692 type = get_node_type((IUnknown*)node);
5693 ok(type == 9, "type=%d, expected 9\n", type);
5694 node2 = test_node_get_parent((IUnknown*)node);
5695 IHTMLDOMNode_Release(node);
5696 ok(node2 == NULL, "node != NULL\n");
5699 elem2 = test_elem_get_parent((IUnknown*)elem);
5700 ok(elem2 != NULL, "elem2 == NULL\n");
5701 test_node_name((IUnknown*)elem2, "BODY");
5702 elem3 = test_elem_get_parent((IUnknown*)elem2);
5703 IHTMLElement_Release(elem2);
5704 ok(elem3 != NULL, "elem3 == NULL\n");
5705 test_node_name((IUnknown*)elem3, "HTML");
5706 elem2 = test_elem_get_parent((IUnknown*)elem3);
5707 IHTMLElement_Release(elem3);
5708 ok(elem2 == NULL, "elem2 != NULL\n");
5710 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5711 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5712 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5714 test_elem_innertext(elem, "opt1opt2");
5716 IHTMLElement_Release(elem);
5719 elem = get_elem_by_id(doc, "s", TRUE);
5720 if(elem) {
5721 IHTMLSelectElement *select = get_select_iface((IUnknown*)elem);
5722 IHTMLDocument2 *doc_node, *elem_doc;
5724 test_select_elem(select);
5726 test_elem_title((IUnknown*)select, NULL);
5727 test_elem_set_title((IUnknown*)select, "Title");
5728 test_elem_title((IUnknown*)select, "Title");
5729 test_elem_offset((IUnknown*)select);
5731 node = get_first_child((IUnknown*)select);
5732 ok(node != NULL, "node == NULL\n");
5733 if(node) {
5734 test_elem_type((IUnknown*)node, ET_OPTION);
5735 IHTMLDOMNode_Release(node);
5738 type = get_node_type((IUnknown*)select);
5739 ok(type == 1, "type=%d\n", type);
5741 IHTMLSelectElement_Release(select);
5743 elem_doc = get_elem_doc((IUnknown*)elem);
5745 doc_node = get_doc_node(doc);
5746 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
5747 IHTMLDocument2_Release(doc_node);
5748 IHTMLDocument2_Release(elem_doc);
5750 IHTMLElement_Release(elem);
5753 elem = get_elem_by_id(doc, "sc", TRUE);
5754 if(elem) {
5755 IHTMLScriptElement *script;
5756 BSTR type;
5758 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5759 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5761 if(hres == S_OK)
5763 VARIANT_BOOL vb;
5765 hres = IHTMLScriptElement_put_type (script, NULL);
5766 ok(hres == S_OK, "put_type failed: %08x\n", hres);
5767 hres = IHTMLScriptElement_get_type(script, &type);
5768 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5769 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
5771 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
5772 ok(hres == S_OK, "put_type failed: %08x\n", hres);
5773 hres = IHTMLScriptElement_get_type(script, &type);
5774 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5775 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5777 SysFreeString(type);
5779 /* test defer */
5780 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5781 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5783 hres = IHTMLScriptElement_get_defer(script, &vb);
5784 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5785 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5787 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5788 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5791 IHTMLScriptElement_Release(script);
5794 elem = get_elem_by_id(doc, "in", TRUE);
5795 if(elem) {
5796 IHTMLInputElement *input;
5798 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5799 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5801 test_elem_id((IUnknown*)elem, "in");
5802 test_elem_put_id((IUnknown*)elem, "newin");
5803 test_input_get_disabled(input, VARIANT_FALSE);
5804 test_input_set_disabled(input, VARIANT_TRUE);
5805 test_input_set_disabled(input, VARIANT_FALSE);
5806 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5807 test_input_get_disabled(input, VARIANT_TRUE);
5808 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5809 test_input_get_disabled(input, VARIANT_FALSE);
5810 test_elem_client_size((IUnknown*)elem);
5811 test_input_type(input, "text");
5813 test_node_get_value_str((IUnknown*)elem, NULL);
5814 test_node_put_value_str((IUnknown*)elem, "test");
5815 test_node_get_value_str((IUnknown*)elem, NULL);
5816 test_input_value((IUnknown*)elem, NULL);
5817 test_input_put_value((IUnknown*)elem, "test");
5818 test_input_value((IUnknown*)elem, NULL);
5819 test_elem_class((IUnknown*)elem, "testclass");
5820 test_elem_tabindex((IUnknown*)elem, 2);
5821 test_elem_set_tabindex((IUnknown*)elem, 3);
5822 test_elem_title((IUnknown*)elem, "test title");
5824 test_input_get_defaultchecked(input, VARIANT_FALSE);
5825 test_input_set_defaultchecked(input, VARIANT_TRUE);
5826 test_input_set_defaultchecked(input, VARIANT_FALSE);
5828 test_input_get_checked(input, VARIANT_FALSE);
5829 test_input_set_checked(input, VARIANT_TRUE);
5830 test_input_set_checked(input, VARIANT_FALSE);
5832 test_input_name(input, NULL);
5833 test_input_set_name(input, "test");
5835 test_input_src(input, NULL);
5836 test_input_set_src(input, "about:blank");
5838 IHTMLInputElement_Release(input);
5839 IHTMLElement_Release(elem);
5842 elem = get_elem_by_id(doc, "imgid", TRUE);
5843 if(elem) {
5844 test_img_src((IUnknown*)elem, "");
5845 test_img_set_src((IUnknown*)elem, "about:blank");
5846 test_img_alt((IUnknown*)elem, NULL);
5847 test_img_set_alt((IUnknown*)elem, "alt test");
5848 test_img_name((IUnknown*)elem, "WineImg");
5849 IHTMLElement_Release(elem);
5852 elem = get_doc_elem_by_id(doc, "tbl");
5853 ok(elem != NULL, "elem == NULL\n");
5854 if(elem) {
5855 test_table_elem(elem);
5856 IHTMLElement_Release(elem);
5859 elem = get_doc_elem_by_id(doc, "row2");
5860 ok(elem != NULL, "elem == NULL\n");
5861 if(elem) {
5862 test_tr_elem(elem);
5863 IHTMLElement_Release(elem);
5866 elem = get_doc_elem_by_id(doc, "ifr");
5867 ok(elem != NULL, "elem == NULL\n");
5868 if(elem) {
5869 test_iframe_elem(elem);
5870 IHTMLElement_Release(elem);
5873 elem = get_elem_by_id(doc, "a", TRUE);
5874 if(elem) {
5875 test_anchor_href((IUnknown*)elem, "http://test/");
5876 IHTMLElement_Release(elem);
5879 hres = IHTMLDocument2_get_body(doc, &elem);
5880 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5882 node = get_first_child((IUnknown*)elem);
5883 ok(node != NULL, "node == NULL\n");
5884 if(node) {
5885 test_ifaces((IUnknown*)node, text_iids);
5886 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5888 node2 = get_first_child((IUnknown*)node);
5889 ok(!node2, "node2 != NULL\n");
5891 type = get_node_type((IUnknown*)node);
5892 ok(type == 3, "type=%d\n", type);
5894 test_node_get_value_str((IUnknown*)node, "text test");
5895 test_node_put_value_str((IUnknown*)elem, "test text");
5896 test_node_get_value_str((IUnknown*)node, "text test");
5898 IHTMLDOMNode_Release(node);
5901 child_col = get_child_nodes((IUnknown*)elem);
5902 ok(child_col != NULL, "child_coll == NULL\n");
5903 if(child_col) {
5904 LONG length = 0;
5906 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5908 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5909 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5910 ok(length, "length=0\n");
5912 node2 = NULL;
5913 node = get_child_item(child_col, 0);
5914 ok(node != NULL, "node == NULL\n");
5915 if(node) {
5916 type = get_node_type((IUnknown*)node);
5917 ok(type == 3, "type=%d\n", type);
5918 node2 = node_get_next((IUnknown*)node);
5919 IHTMLDOMNode_Release(node);
5922 node = get_child_item(child_col, 1);
5923 ok(node != NULL, "node == NULL\n");
5924 if(node) {
5925 type = get_node_type((IUnknown*)node);
5926 ok(type == 8, "type=%d\n", type);
5928 test_elem_id((IUnknown*)node, NULL);
5929 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
5930 IHTMLDOMNode_Release(node2);
5931 IHTMLDOMNode_Release(node);
5934 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5935 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5937 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5938 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5940 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5941 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5943 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5944 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5946 test_child_col_disp(child_col);
5948 IHTMLDOMChildrenCollection_Release(child_col);
5951 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5952 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5953 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5955 IHTMLElement_Release(elem);
5957 elem = get_doc_elem_by_id(doc, "frm");
5958 ok(elem != NULL, "elem == NULL\n");
5959 if(elem) {
5960 test_form_length((IUnknown*)elem, 0);
5961 IHTMLElement_Release(elem);
5964 test_stylesheets(doc);
5965 test_create_option_elem(doc);
5966 test_create_img_elem(doc);
5968 elem = get_doc_elem_by_id(doc, "tbl");
5969 ok(elem != NULL, "elem = NULL\n");
5970 test_elem_set_innertext(elem, "inner text");
5971 IHTMLElement_Release(elem);
5973 test_doc_title(doc, "test");
5974 test_doc_set_title(doc, "test title");
5975 test_doc_title(doc, "test title");
5977 disp = NULL;
5978 hres = IHTMLDocument2_get_Script(doc, &disp);
5979 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5980 if(hres == S_OK)
5982 IDispatchEx *dispex;
5983 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5984 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5985 if(hres == S_OK)
5987 DISPID pid = -1;
5988 BSTR str = a2bstr("Testing");
5989 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5990 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5991 ok(pid != -1, "pid == -1\n");
5992 SysFreeString(str);
5993 IDispatchEx_Release(dispex);
5996 IDispatch_Release(disp);
5998 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5999 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
6001 str = a2bstr("img");
6002 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
6003 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
6004 SysFreeString(str);
6005 if(hres == S_OK)
6007 static const elem_type_t img_types[] = { ET_IMG };
6009 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
6010 IHTMLElementCollection_Release(col);
6013 elem = get_doc_elem_by_id(doc, "y");
6014 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
6015 test_elem_innerhtml((IUnknown*)elem, "inner html");
6016 test_elem_set_innerhtml((IUnknown*)elem, "");
6017 test_elem_innerhtml((IUnknown*)elem, NULL);
6018 node = node_get_next((IUnknown*)elem);
6019 ok(!node, "node = %p\n", node);
6021 elem2 = get_doc_elem_by_id(doc, "x");
6022 test_elem_tag((IUnknown*)elem2, "A");
6023 node = node_get_next((IUnknown*)elem2);
6024 IHTMLDOMNode_Release(node);
6025 IHTMLElement_Release(elem2);
6026 IHTMLElement_Release(elem);
6028 IHTMLDocument3_Release(doc3);
6030 elem = get_elem_by_id(doc, "s", TRUE);
6031 if(elem) {
6032 static const elem_type_t select_types[] = { ET_OPTION, ET_OPTION, ET_OPTION };
6034 test_select_put_length((IUnknown*)elem, 3);
6035 test_elem_all((IUnknown*)elem, select_types, sizeof(select_types)/sizeof(*select_types));
6036 test_select_put_length((IUnknown*)elem, 1);
6037 test_elem_all((IUnknown*)elem, select_types, 1);
6038 IHTMLElement_Release(elem);
6041 window = get_doc_window(doc);
6042 test_window_name(window, NULL);
6043 set_window_name(window, "test name");
6044 test_window_length(window, 1);
6045 IHTMLWindow2_Release(window);
6048 static void test_elems2(IHTMLDocument2 *doc)
6050 IHTMLElement *elem, *elem2, *div;
6052 static const elem_type_t outer_types[] = {
6053 ET_BR,
6054 ET_A
6057 div = get_doc_elem_by_id(doc, "divid");
6059 test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
6060 elem2 = get_doc_elem_by_id(doc, "innerid");
6061 ok(elem2 != NULL, "elem2 == NULL\n");
6062 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
6063 test_elem_all((IUnknown*)div, outer_types, sizeof(outer_types)/sizeof(*outer_types));
6064 IHTMLElement_Release(elem2);
6066 elem2 = get_doc_elem_by_id(doc, "aid");
6067 ok(elem2 != NULL, "elem2 == NULL\n");
6068 test_elem_set_outerhtml((IUnknown*)elem2, "");
6069 test_elem_all((IUnknown*)div, outer_types, 1);
6070 IHTMLElement_Release(elem2);
6072 test_elem_set_innerhtml((IUnknown*)div, "<textarea id=\"ta\"></textarea>");
6073 elem = get_elem_by_id(doc, "ta", TRUE);
6074 if(elem) {
6075 test_textarea_value((IUnknown*)elem, NULL);
6076 test_textarea_put_value((IUnknown*)elem, "test");
6077 IHTMLElement_Release(elem);
6080 IHTMLElement_Release(div);
6083 static void test_create_elems(IHTMLDocument2 *doc)
6085 IHTMLElement *elem, *body, *elem2;
6086 IHTMLDOMNode *node, *node2, *node3, *comment;
6087 IHTMLDocument5 *doc5;
6088 IDispatch *disp;
6089 VARIANT var;
6090 LONG type;
6091 HRESULT hres;
6092 BSTR str;
6094 static const elem_type_t types1[] = { ET_TESTG };
6096 elem = test_create_elem(doc, "TEST");
6097 test_elem_tag((IUnknown*)elem, "TEST");
6098 type = get_node_type((IUnknown*)elem);
6099 ok(type == 1, "type=%d\n", type);
6100 test_ifaces((IUnknown*)elem, elem_iids);
6101 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
6103 hres = IHTMLDocument2_get_body(doc, &body);
6104 ok(hres == S_OK, "get_body failed: %08x\n", hres);
6105 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6107 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
6108 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
6109 elem2 = get_elem_iface((IUnknown*)node);
6110 IHTMLElement_Release(elem2);
6112 hres = IHTMLElement_get_all(body, &disp);
6113 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6114 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
6115 IDispatch_Release(disp);
6117 test_node_remove_child((IUnknown*)body, node);
6119 hres = IHTMLElement_get_all(body, &disp);
6120 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6121 test_elem_collection((IUnknown*)disp, NULL, 0);
6122 IDispatch_Release(disp);
6123 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6125 IHTMLElement_Release(elem);
6126 IHTMLDOMNode_Release(node);
6128 node = test_create_text(doc, "test");
6129 test_ifaces((IUnknown*)node, text_iids);
6130 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6131 test_text_length((IUnknown*)node, 4);
6133 V_VT(&var) = VT_NULL;
6134 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
6135 IHTMLDOMNode_Release(node);
6137 node = test_create_text(doc, "insert ");
6139 V_VT(&var) = VT_DISPATCH;
6140 V_DISPATCH(&var) = (IDispatch*)node2;
6141 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
6142 IHTMLDOMNode_Release(node);
6143 IHTMLDOMNode_Release(node2);
6144 IHTMLDOMNode_Release(node3);
6146 test_elem_innertext(body, "insert test");
6147 test_elem_innerhtml((IUnknown*)body, "insert test");
6149 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
6150 if(hres == S_OK)
6152 str = a2bstr("testing");
6153 hres = IHTMLDocument5_createComment(doc5, str, &comment);
6154 SysFreeString(str);
6155 ok(hres == S_OK, "createComment failed: %08x\n", hres);
6156 if(hres == S_OK)
6158 type = get_node_type((IUnknown*)comment);
6159 ok(type == 8, "type=%d, expected 8\n", type);
6161 test_node_get_value_str((IUnknown*)comment, "testing");
6162 test_elem_title((IUnknown*)comment, NULL);
6163 test_elem_set_title((IUnknown*)comment, "comment title");
6164 test_elem_title((IUnknown*)comment, "comment title");
6165 test_comment_text((IUnknown*)comment, "<!--testing-->");
6166 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
6168 IHTMLDOMNode_Release(comment);
6171 IHTMLDocument5_Release(doc5);
6174 IHTMLElement_Release(body);
6177 static void test_null_write(IHTMLDocument2 *doc)
6179 HRESULT hres;
6181 doc_write(doc, FALSE, NULL);
6182 doc_write(doc, TRUE, NULL);
6184 hres = IHTMLDocument2_write(doc, NULL);
6185 ok(hres == S_OK,
6186 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
6188 hres = IHTMLDocument2_writeln(doc, NULL);
6189 ok(hres == S_OK,
6190 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
6193 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
6195 IOleCommandTarget *cmdtrg;
6196 HRESULT hres;
6198 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
6199 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
6201 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
6202 ok(hres == S_OK, "Exec failed: %08x\n", hres);
6204 IOleCommandTarget_Release(cmdtrg);
6207 static void test_indent(IHTMLDocument2 *doc)
6209 IHTMLElementCollection *col;
6210 IHTMLTxtRange *range;
6211 HRESULT hres;
6213 static const elem_type_t all_types[] = {
6214 ET_HTML,
6215 ET_HEAD,
6216 ET_TITLE,
6217 ET_BODY,
6218 ET_BR,
6219 ET_A,
6222 static const elem_type_t indent_types[] = {
6223 ET_HTML,
6224 ET_HEAD,
6225 ET_TITLE,
6226 ET_BODY,
6227 ET_BLOCKQUOTE,
6228 ET_P,
6229 ET_BR,
6230 ET_A,
6233 hres = IHTMLDocument2_get_all(doc, &col);
6234 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6235 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6236 IHTMLElementCollection_Release(col);
6238 range = test_create_body_range(doc);
6239 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
6240 IHTMLTxtRange_Release(range);
6242 hres = IHTMLDocument2_get_all(doc, &col);
6243 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6244 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
6245 IHTMLElementCollection_Release(col);
6248 static void test_cond_comment(IHTMLDocument2 *doc)
6250 IHTMLElementCollection *col;
6251 HRESULT hres;
6253 static const elem_type_t all_types[] = {
6254 ET_HTML,
6255 ET_HEAD,
6256 ET_TITLE,
6257 ET_BODY,
6258 ET_BR
6261 hres = IHTMLDocument2_get_all(doc, &col);
6262 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6263 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6264 IHTMLElementCollection_Release(col);
6267 static void test_frame(IDispatch *disp, const char *exp_id)
6269 IHTMLWindow2 *frame2, *parent, *top;
6270 IHTMLDocument2 *parent_doc, *top_doc;
6271 IHTMLWindow4 *frame;
6272 IHTMLFrameBase *frame_elem;
6273 HRESULT hres;
6275 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
6276 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
6277 if(FAILED(hres))
6278 return;
6280 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
6281 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
6282 IHTMLWindow4_Release(frame);
6283 if(FAILED(hres))
6284 return;
6286 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
6287 test_frame_doc((IUnknown*)frame_elem, FALSE);
6288 test_elem_id((IUnknown*)frame_elem, exp_id);
6289 IHTMLElement_Release(frame_elem);
6291 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
6292 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
6293 if(FAILED(hres))
6294 return;
6296 hres = IHTMLWindow2_get_parent(frame2, &parent);
6297 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
6298 if(FAILED(hres)){
6299 IHTMLWindow2_Release(frame2);
6300 return;
6303 hres = IHTMLWindow2_get_document(parent, &parent_doc);
6304 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6305 IHTMLWindow2_Release(parent);
6306 if(FAILED(hres)){
6307 IHTMLWindow2_Release(frame2);
6308 return;
6311 test_doc_title(parent_doc, "frameset test");
6312 IHTMLDocument2_Release(parent_doc);
6314 /* test get_top */
6315 hres = IHTMLWindow2_get_top(frame2, &top);
6316 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
6317 IHTMLWindow2_Release(frame2);
6318 if(FAILED(hres))
6319 return;
6321 hres = IHTMLWindow2_get_document(top, &top_doc);
6322 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6323 IHTMLWindow2_Release(top);
6324 if(FAILED(hres))
6325 return;
6327 test_doc_title(top_doc, "frameset test");
6328 IHTMLDocument2_Release(top_doc);
6331 static void test_frameset(IHTMLDocument2 *doc)
6333 IHTMLWindow2 *window;
6334 IHTMLFramesCollection2 *frames;
6335 IHTMLElement *elem;
6336 IHTMLFrameBase *fbase;
6337 LONG length;
6338 VARIANT index_var, result_var;
6339 BSTR str;
6340 HRESULT hres;
6342 window = get_doc_window(doc);
6344 /* test using IHTMLFramesCollection object */
6346 hres = IHTMLWindow2_get_frames(window, &frames);
6347 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
6348 IHTMLWindow2_Release(window);
6349 if(FAILED(hres))
6350 return;
6352 /* test result length */
6353 hres = IHTMLFramesCollection2_get_length(frames, &length);
6354 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
6355 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
6357 /* test first frame */
6358 V_VT(&index_var) = VT_I4;
6359 V_I4(&index_var) = 0;
6360 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6361 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6362 if(SUCCEEDED(hres)) {
6363 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6364 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6366 VariantClear(&result_var);
6368 /* test second frame */
6369 V_I4(&index_var) = 1;
6370 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6371 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6372 if(SUCCEEDED(hres)) {
6373 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6374 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6376 VariantClear(&result_var);
6378 /* fail on next frame */
6379 V_I4(&index_var) = 3;
6380 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6381 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
6382 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6383 VariantClear(&result_var);
6385 /* string argument (element id lookup) */
6386 V_VT(&index_var) = VT_BSTR;
6387 V_BSTR(&index_var) = a2bstr("fr1");
6388 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6389 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6390 if(SUCCEEDED(hres)) {
6391 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6392 test_frame(V_DISPATCH(&result_var), "fr1");
6394 VariantClear(&result_var);
6395 VariantClear(&index_var);
6397 /* invalid argument */
6398 V_VT(&index_var) = VT_BOOL;
6399 V_BOOL(&index_var) = VARIANT_TRUE;
6400 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6401 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
6402 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6403 VariantClear(&result_var);
6405 IHTMLFramesCollection2_Release(frames);
6407 /* test using IHTMLWindow2 inheritance */
6409 /* test result length */
6410 hres = IHTMLWindow2_get_length(window, &length);
6411 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
6412 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
6414 /* test first frame */
6415 V_VT(&index_var) = VT_I4;
6416 V_I4(&index_var) = 0;
6417 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6418 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6419 if(SUCCEEDED(hres)) {
6420 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6421 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6423 VariantClear(&result_var);
6425 /* test second frame */
6426 V_I4(&index_var) = 1;
6427 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6428 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6429 if(SUCCEEDED(hres)) {
6430 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6431 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6433 VariantClear(&result_var);
6435 /* fail on next frame */
6436 V_I4(&index_var) = 3;
6437 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6438 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
6439 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6440 VariantClear(&result_var);
6442 /* string argument (element id lookup) */
6443 V_VT(&index_var) = VT_BSTR;
6444 V_BSTR(&index_var) = a2bstr("fr2");
6445 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6446 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6447 if(SUCCEEDED(hres)) {
6448 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6449 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6451 VariantClear(&result_var);
6452 VariantClear(&index_var);
6454 /* invalid argument */
6455 V_VT(&index_var) = VT_BOOL;
6456 V_BOOL(&index_var) = VARIANT_TRUE;
6457 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6458 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
6459 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6460 VariantClear(&result_var);
6462 /* getElementById with node name attributes */
6463 elem = get_doc_elem_by_id(doc, "nm1");
6464 test_elem_id((IUnknown*)elem, "fr1");
6466 /* get/put scrolling */
6467 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6468 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6470 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6471 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6472 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
6473 SysFreeString(str);
6475 str = a2bstr("no");
6476 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6477 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
6478 SysFreeString(str);
6480 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6481 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6482 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6483 SysFreeString(str);
6485 str = a2bstr("junk");
6486 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6487 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
6488 "with E_INVALIDARG, instead: 0x%08x\n", hres);
6489 SysFreeString(str);
6491 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6492 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6493 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6494 SysFreeString(str);
6496 /* get_name */
6497 hres = IHTMLFrameBase_get_name(fbase, &str);
6498 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6499 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
6500 SysFreeString(str);
6502 IHTMLFrameBase_Release(fbase);
6503 IHTMLElement_Release(elem);
6505 /* get_name with no name attr */
6506 elem = get_doc_elem_by_id(doc, "fr3");
6507 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6508 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6510 hres = IHTMLFrameBase_get_name(fbase, &str);
6511 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6512 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
6513 SysFreeString(str);
6515 IHTMLFrameBase_Release(fbase);
6516 IHTMLElement_Release(elem);
6519 static IHTMLDocument2 *notif_doc;
6520 static BOOL doc_complete;
6522 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
6523 REFIID riid, void**ppv)
6525 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
6526 *ppv = iface;
6527 return S_OK;
6530 ok(0, "unexpected call\n");
6531 return E_NOINTERFACE;
6534 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
6536 return 2;
6539 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
6541 return 1;
6544 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
6546 if(dispID == DISPID_READYSTATE){
6547 BSTR state;
6548 HRESULT hres;
6550 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
6551 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
6553 if(!strcmp_wa(state, "complete"))
6554 doc_complete = TRUE;
6556 SysFreeString(state);
6559 return S_OK;
6562 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
6564 ok(0, "unexpected call\n");
6565 return E_NOTIMPL;
6568 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
6569 PropertyNotifySink_QueryInterface,
6570 PropertyNotifySink_AddRef,
6571 PropertyNotifySink_Release,
6572 PropertyNotifySink_OnChanged,
6573 PropertyNotifySink_OnRequestEdit
6576 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
6578 static IHTMLDocument2 *create_doc_with_string(const char *str)
6580 IPersistStreamInit *init;
6581 IStream *stream;
6582 IHTMLDocument2 *doc;
6583 HGLOBAL mem;
6584 SIZE_T len;
6586 notif_doc = doc = create_document();
6587 if(!doc)
6588 return NULL;
6590 doc_complete = FALSE;
6591 len = strlen(str);
6592 mem = GlobalAlloc(0, len);
6593 memcpy(mem, str, len);
6594 CreateStreamOnHGlobal(mem, TRUE, &stream);
6596 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
6598 IPersistStreamInit_Load(init, stream);
6599 IPersistStreamInit_Release(init);
6600 IStream_Release(stream);
6602 return doc;
6605 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
6607 IConnectionPointContainer *container;
6608 IConnectionPoint *cp;
6609 DWORD cookie;
6610 HRESULT hres;
6612 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
6613 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
6615 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
6616 IConnectionPointContainer_Release(container);
6617 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
6619 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
6620 IConnectionPoint_Release(cp);
6621 ok(hres == S_OK, "Advise failed: %08x\n", hres);
6624 typedef void (*domtest_t)(IHTMLDocument2*);
6626 static void run_domtest(const char *str, domtest_t test)
6628 IHTMLDocument2 *doc;
6629 ULONG ref;
6630 MSG msg;
6632 doc = create_doc_with_string(str);
6633 if(!doc)
6634 return;
6636 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
6638 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
6639 TranslateMessage(&msg);
6640 DispatchMessage(&msg);
6643 test(doc);
6645 ref = IHTMLDocument2_Release(doc);
6646 ok(!ref ||
6647 ref == 1, /* Vista */
6648 "ref = %d\n", ref);
6651 START_TEST(dom)
6653 CoInitialize(NULL);
6655 run_domtest(doc_str1, test_doc_elem);
6656 run_domtest(doc_str1, test_get_set_attr);
6657 run_domtest(range_test_str, test_txtrange);
6658 run_domtest(range_test2_str, test_txtrange2);
6659 if (winetest_interactive || ! is_ie_hardened()) {
6660 run_domtest(elem_test_str, test_elems);
6661 }else {
6662 skip("IE running in Enhanced Security Configuration\n");
6664 run_domtest(elem_test2_str, test_elems2);
6665 run_domtest(doc_blank, test_create_elems);
6666 run_domtest(doc_blank, test_defaults);
6667 run_domtest(doc_blank, test_null_write);
6668 run_domtest(indent_test_str, test_indent);
6669 run_domtest(cond_comment_str, test_cond_comment);
6670 run_domtest(frameset_str, test_frameset);
6672 CoUninitialize();