mshtml: Use set_nsstyle_attr_var in IHTMLStyle::put_width implementation.
[wine/hacks.git] / dlls / mshtml / tests / dom.c
blobaa09d9e97b74e00ce320ea3cb81c7dd7ac38fa80
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_disp(__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_text_iface(u) _get_text_iface(__LINE__,u)
677 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
679 IHTMLDOMTextNode *text;
680 HRESULT hres;
682 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
683 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
684 return text;
687 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
688 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
690 IHTMLDOMNode *node = _get_node_iface(line, unk);
691 BSTR name;
692 HRESULT hres;
694 hres = IHTMLDOMNode_get_nodeName(node, &name);
695 IHTMLDOMNode_Release(node);
696 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
697 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
699 SysFreeString(name);
702 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
703 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
705 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
706 IDispatch *disp = (void*)0xdeadbeef;
707 IHTMLDocument2 *doc = NULL;
708 HRESULT hres;
710 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
711 IHTMLDOMNode2_Release(node);
712 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
714 if(disp) {
715 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
716 IDispatch_Release(disp);
717 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
720 return doc;
723 #define get_doc_window(d) _get_doc_window(__LINE__,d)
724 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
726 IHTMLWindow2 *window;
727 HRESULT hres;
729 window = NULL;
730 hres = IHTMLDocument2_get_parentWindow(doc, &window);
731 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
732 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
734 return window;
737 #define clone_node(n,d) _clone_node(__LINE__,n,d)
738 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
740 IHTMLDOMNode *node = _get_node_iface(line, unk);
741 IHTMLDOMNode *ret = NULL;
742 HRESULT hres;
744 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
745 IHTMLDOMNode_Release(node);
746 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
747 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
749 return ret;
753 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
754 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
756 IHTMLElement *elem = _get_elem_iface(line, unk);
757 BSTR tag;
758 HRESULT hres;
760 hres = IHTMLElement_get_tagName(elem, &tag);
761 IHTMLElement_Release(elem);
762 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
763 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
765 SysFreeString(tag);
768 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
769 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
771 _test_elem_tag(line, unk, elem_type_infos[type].tag);
772 _test_ifaces(line, unk, elem_type_infos[type].iids);
774 if(elem_type_infos[type].dispiid && type != ET_A)
775 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
778 #define get_node_type(n) _get_node_type(__LINE__,n)
779 static LONG _get_node_type(unsigned line, IUnknown *unk)
781 IHTMLDOMNode *node = _get_node_iface(line, unk);
782 LONG type = -1;
783 HRESULT hres;
785 hres = IHTMLDOMNode_get_nodeType(node, &type);
786 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
788 IHTMLDOMNode_Release(node);
790 return type;
793 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
794 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
796 IHTMLDOMNode *node = _get_node_iface(line, unk);
797 IHTMLDOMChildrenCollection *col = NULL;
798 IDispatch *disp;
799 HRESULT hres;
801 hres = IHTMLDOMNode_get_childNodes(node, &disp);
802 IHTMLDOMNode_Release(node);
803 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
804 if(FAILED(hres))
805 return NULL;
807 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
808 IDispatch_Release(disp);
809 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
811 return col;
814 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
815 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
817 IHTMLDOMNode *node = NULL;
818 IDispatch *disp;
819 HRESULT hres;
821 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
822 ok(hres == S_OK, "item failed: %08x\n", hres);
824 node = _get_node_iface(line, (IUnknown*)disp);
825 IDispatch_Release(disp);
827 return node;
830 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
831 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
833 VARIANT value;
834 BSTR tmp;
835 HRESULT hres;
837 VariantInit(&value);
839 tmp = a2bstr(name);
840 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
841 SysFreeString(tmp);
842 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
844 if(exval) {
845 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
846 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
847 }else {
848 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
851 VariantClear(&value);
854 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
855 static void _test_elem_offset(unsigned line, IUnknown *unk)
857 IHTMLElement *elem = _get_elem_iface(line, unk);
858 LONG l;
859 HRESULT hres;
861 hres = IHTMLElement_get_offsetTop(elem, &l);
862 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
864 hres = IHTMLElement_get_offsetHeight(elem, &l);
865 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
867 hres = IHTMLElement_get_offsetWidth(elem, &l);
868 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
870 IHTMLElement_Release(elem);
873 #define get_doc_node(d) _get_doc_node(__LINE__,d)
874 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
876 IHTMLWindow2 *window;
877 IHTMLDocument2 *ret;
878 HRESULT hres;
880 hres = IHTMLDocument2_get_parentWindow(doc, &window);
881 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
883 hres = IHTMLWindow2_get_document(window, &ret);
884 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
885 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
887 return ret;
890 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
891 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
893 BSTR name;
894 HRESULT hres;
896 hres = IHTMLWindow2_get_name(window, &name);
897 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
898 if(exname)
899 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
900 else
901 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
904 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
905 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
907 BSTR str;
908 HRESULT hres;
910 str = a2bstr(name);
911 hres = IHTMLWindow2_put_name(window, str);
912 SysFreeString(str);
913 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
915 _test_window_name(line, window, name);
918 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
919 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
921 LONG length = -1;
922 HRESULT hres;
924 hres = IHTMLWindow2_get_length(window, &length);
925 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
926 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
929 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
930 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
932 IHTMLFrameBase2 *base2;
933 IHTMLWindow2 *window;
934 HRESULT hres;
936 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
937 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
939 window = NULL;
940 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
941 IHTMLFrameBase2_Release(base2);
942 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
943 ok(window != NULL, "contentWindow = NULL\n");
945 return window;
948 static void test_get_set_attr(IHTMLDocument2 *doc)
950 IHTMLElement *elem;
951 IHTMLDocument3 *doc3;
952 HRESULT hres;
953 BSTR bstr;
954 VARIANT val;
956 /* grab an element to test with */
957 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
958 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
960 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
961 IHTMLDocument3_Release(doc3);
962 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
964 /* get a non-present attribute */
965 bstr = a2bstr("notAnAttribute");
966 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
967 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
968 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
969 VariantClear(&val);
970 SysFreeString(bstr);
972 /* get a present attribute */
973 bstr = a2bstr("scrollHeight");
974 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
975 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
976 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
977 VariantClear(&val);
978 SysFreeString(bstr);
980 /* create a new BSTR attribute */
981 bstr = a2bstr("newAttribute");
983 V_VT(&val) = VT_BSTR;
984 V_BSTR(&val) = a2bstr("the value");
985 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
986 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
987 VariantClear(&val);
989 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
990 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
991 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
992 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)));
993 VariantClear(&val);
995 /* overwrite the attribute with a BOOL */
996 V_VT(&val) = VT_BOOL;
997 V_BOOL(&val) = VARIANT_TRUE;
998 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
999 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1000 VariantClear(&val);
1002 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1003 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1004 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1005 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1006 VariantClear(&val);
1008 SysFreeString(bstr);
1010 /* case-insensitive */
1011 bstr = a2bstr("newattribute");
1012 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1013 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1014 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1015 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1016 VariantClear(&val);
1017 SysFreeString(bstr);
1019 IHTMLElement_Release(elem);
1022 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1023 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1025 IHTMLElement *elem;
1026 IHTMLDocument3 *doc3;
1027 HRESULT hres;
1029 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1030 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1031 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1032 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1033 IHTMLDocument3_Release(doc3);
1035 return elem;
1038 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1039 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1041 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1042 BSTR str;
1043 HRESULT hres;
1045 hres = IHTMLAnchorElement_get_href(anchor, &str);
1046 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1047 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1048 SysFreeString(str);
1050 _test_disp_value(line, unk, exhref);
1053 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1054 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1056 BSTR bstr;
1057 HRESULT hres;
1059 hres = IHTMLOptionElement_get_text(option, &bstr);
1060 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1061 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1062 SysFreeString(bstr);
1065 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1066 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1068 BSTR bstr;
1069 HRESULT hres;
1071 bstr = a2bstr(text);
1072 hres = IHTMLOptionElement_put_text(option, bstr);
1073 SysFreeString(bstr);
1074 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1076 _test_option_text(line, option, text);
1079 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1080 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1082 BSTR bstr;
1083 HRESULT hres;
1085 hres = IHTMLOptionElement_get_value(option, &bstr);
1086 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1087 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1088 SysFreeString(bstr);
1091 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1092 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1094 BSTR bstr;
1095 HRESULT hres;
1097 bstr = a2bstr(value);
1098 hres = IHTMLOptionElement_put_value(option, bstr);
1099 SysFreeString(bstr);
1100 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1102 _test_option_value(line, option, value);
1105 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1106 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1107 const char *txt, const char *val)
1109 IHTMLOptionElementFactory *factory;
1110 IHTMLOptionElement *option;
1111 IHTMLWindow2 *window;
1112 VARIANT text, value, empty;
1113 HRESULT hres;
1115 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1116 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1118 hres = IHTMLWindow2_get_Option(window, &factory);
1119 IHTMLWindow2_Release(window);
1120 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1122 V_VT(&text) = VT_BSTR;
1123 V_BSTR(&text) = a2bstr(txt);
1124 V_VT(&value) = VT_BSTR;
1125 V_BSTR(&value) = a2bstr(val);
1126 V_VT(&empty) = VT_EMPTY;
1128 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1129 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1131 IHTMLOptionElementFactory_Release(factory);
1132 VariantClear(&text);
1133 VariantClear(&value);
1135 _test_option_text(line, option, txt);
1136 _test_option_value(line, option, val);
1138 return option;
1141 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1142 static void _test_img_width(unsigned line, IHTMLImgElement *img, const long exp)
1144 LONG found = -1;
1145 HRESULT hres;
1147 hres = IHTMLImgElement_get_width(img, &found);
1148 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1149 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1152 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1153 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const long width)
1155 HRESULT hres;
1157 hres = IHTMLImgElement_put_width(img, width);
1158 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1160 _test_img_width(line, img, width);
1163 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1164 static void _test_img_height(unsigned line, IHTMLImgElement *img, const long exp)
1166 LONG found = -1;
1167 HRESULT hres;
1169 hres = IHTMLImgElement_get_height(img, &found);
1170 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1171 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1174 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1175 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const long height)
1177 HRESULT hres;
1179 hres = IHTMLImgElement_put_height(img, height);
1180 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1182 _test_img_height(line, img, height);
1185 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1186 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1187 LONG wdth, LONG hght)
1189 IHTMLImageElementFactory *factory;
1190 IHTMLImgElement *img;
1191 IHTMLWindow2 *window;
1192 VARIANT width, height;
1193 char buf[16];
1194 HRESULT hres;
1196 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1197 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1199 hres = IHTMLWindow2_get_Image(window, &factory);
1200 IHTMLWindow2_Release(window);
1201 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1203 test_ifaces((IUnknown*)factory, img_factory_iids);
1204 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1206 if(wdth >= 0){
1207 snprintf(buf, 16, "%d", wdth);
1208 V_VT(&width) = VT_BSTR;
1209 V_BSTR(&width) = a2bstr(buf);
1210 }else{
1211 V_VT(&width) = VT_EMPTY;
1212 wdth = 0;
1215 if(hght >= 0){
1216 snprintf(buf, 16, "%d", hght);
1217 V_VT(&height) = VT_BSTR;
1218 V_BSTR(&height) = a2bstr(buf);
1219 }else{
1220 V_VT(&height) = VT_EMPTY;
1221 hght = 0;
1224 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1225 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1227 IHTMLImageElementFactory_Release(factory);
1228 VariantClear(&width);
1229 VariantClear(&height);
1231 if(SUCCEEDED(hres)) {
1232 _test_img_width(line, img, wdth);
1233 _test_img_height(line, img, hght);
1234 return img;
1237 return NULL;
1240 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1241 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1243 LONG len = 0xdeadbeef;
1244 HRESULT hres;
1246 hres = IHTMLSelectElement_get_length(select, &len);
1247 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1248 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1251 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1252 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1254 LONG idx = 0xdeadbeef;
1255 HRESULT hres;
1257 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1258 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1259 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1262 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1263 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1265 HRESULT hres;
1267 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1268 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1269 _test_select_selidx(line, select, index);
1272 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1273 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1275 BSTR val;
1276 HRESULT hres;
1278 hres = IHTMLSelectElement_get_value(select, &val);
1279 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1280 if(exval)
1281 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1282 else
1283 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1286 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1287 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1289 BSTR bstr;
1290 HRESULT hres;
1292 bstr = a2bstr(val);
1293 hres = IHTMLSelectElement_put_value(select, bstr);
1294 SysFreeString(bstr);
1295 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1298 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1299 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1301 BSTR type;
1302 HRESULT hres;
1304 hres = IHTMLSelectElement_get_type(select, &type);
1305 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1306 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1309 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1310 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1312 BSTR text;
1313 HRESULT hres;
1315 hres = IHTMLTxtRange_get_text(range, &text);
1316 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1318 if(extext) {
1319 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1320 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1321 }else {
1322 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1325 SysFreeString(text);
1329 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1330 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1332 HRESULT hres;
1334 hres = IHTMLTxtRange_collapse(range, b);
1335 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1336 _test_range_text(line, range, NULL);
1339 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1340 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1341 VARIANT_BOOL exb, const char *extext)
1343 VARIANT_BOOL b = 0xe0e0;
1344 HRESULT hres;
1346 hres = IHTMLTxtRange_expand(range, unit, &b);
1347 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1348 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1349 _test_range_text(line, range, extext);
1352 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1353 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1355 LONG c = 0xdeadbeef;
1356 HRESULT hres;
1358 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1359 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1360 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1361 _test_range_text(line, range, NULL);
1364 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1365 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1366 LPWSTR unit, LONG cnt, LONG excnt)
1368 LONG c = 0xdeadbeef;
1369 HRESULT hres;
1371 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1372 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1373 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1376 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1377 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1379 LONG c = 0xdeadbeef;
1380 HRESULT hres;
1382 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1383 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1384 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1387 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1388 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1390 HRESULT hres;
1391 BSTR bstr = a2bstr(text);
1393 hres = IHTMLTxtRange_put_text(range, bstr);
1394 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1395 SysFreeString(bstr);
1396 _test_range_text(line, range, NULL);
1399 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1400 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1402 VARIANT_BOOL b;
1403 HRESULT hres;
1405 b = 0xe0e0;
1406 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1407 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1408 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1411 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1412 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1414 VARIANT_BOOL b;
1415 HRESULT hres;
1417 b = 0xe0e0;
1418 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1419 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1420 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1422 b = 0xe0e0;
1423 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1424 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1425 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1427 if(exb) {
1428 test_range_inrange(range1, range2, VARIANT_TRUE);
1429 test_range_inrange(range2, range1, VARIANT_TRUE);
1433 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1434 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1436 IHTMLElement *elem;
1437 HRESULT hres;
1439 hres = IHTMLTxtRange_parentElement(range, &elem);
1440 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1442 _test_elem_type(line, (IUnknown*)elem, type);
1444 IHTMLElement_Release(elem);
1447 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1448 static void _test_elem_collection(unsigned line, IUnknown *unk,
1449 const elem_type_t *elem_types, LONG exlen)
1451 IHTMLElementCollection *col;
1452 LONG len;
1453 DWORD i;
1454 VARIANT name, index;
1455 IDispatch *disp, *disp2;
1456 HRESULT hres;
1458 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1459 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1461 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1463 hres = IHTMLElementCollection_get_length(col, &len);
1464 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1465 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1467 if(len > exlen)
1468 len = exlen;
1470 V_VT(&index) = VT_EMPTY;
1472 for(i=0; i<len; i++) {
1473 V_VT(&name) = VT_I4;
1474 V_I4(&name) = i;
1475 disp = (void*)0xdeadbeef;
1476 hres = IHTMLElementCollection_item(col, name, index, &disp);
1477 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1478 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1479 if(FAILED(hres) || !disp)
1480 continue;
1482 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1484 if(!i) {
1485 V_VT(&name) = VT_UINT;
1486 V_I4(&name) = 0;
1487 disp2 = (void*)0xdeadbeef;
1488 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1489 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1490 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1491 if(disp2)
1492 IDispatch_Release(disp2);
1495 IDispatch_Release(disp);
1498 V_VT(&name) = VT_I4;
1499 V_I4(&name) = len;
1500 disp = (void*)0xdeadbeef;
1501 hres = IHTMLElementCollection_item(col, name, index, &disp);
1502 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1503 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1505 V_VT(&name) = VT_I4;
1506 V_I4(&name) = -1;
1507 disp = (void*)0xdeadbeef;
1508 hres = IHTMLElementCollection_item(col, name, index, &disp);
1509 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1510 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1512 IHTMLElementCollection_Release(col);
1515 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1516 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1518 IHTMLElement *elem = _get_elem_iface(line, unk);
1519 IDispatch *disp;
1520 HRESULT hres;
1522 hres = IHTMLElement_get_all(elem, &disp);
1523 IHTMLElement_Release(elem);
1524 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1526 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1527 IDispatch_Release(disp);
1530 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1531 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1533 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1534 IHTMLElementCollection *col = NULL;
1535 elem_type_t *types = NULL;
1536 BSTR tmp;
1537 int i;
1538 HRESULT hres;
1540 tmp = a2bstr(elem_type_infos[type].tag);
1541 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1542 SysFreeString(tmp);
1543 IHTMLElement2_Release(elem);
1544 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1545 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1547 if(exlen) {
1548 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1549 for(i=0; i<exlen; i++)
1550 types[i] = type;
1553 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1555 HeapFree(GetProcessHeap(), 0, types);
1558 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1559 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1561 BSTR text = NULL;
1562 HRESULT hres;
1564 hres = IHTMLElement_get_innerText(elem, &text);
1565 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1566 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1567 wine_dbgstr_w(text), extext);
1568 SysFreeString(text);
1571 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1572 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1574 IHTMLDOMChildrenCollection *col;
1575 BSTR str;
1576 HRESULT hres;
1578 str = a2bstr(text);
1579 hres = IHTMLElement_put_innerText(elem, str);
1580 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1581 SysFreeString(str);
1583 _test_elem_innertext(line, elem, text);
1586 col = _get_child_nodes(line, (IUnknown*)elem);
1587 ok(col != NULL, "col == NULL\n");
1588 if(col) {
1589 LONG length = 0, type;
1590 IHTMLDOMNode *node;
1592 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1593 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1594 ok(length == 1, "length = %d\n", length);
1596 node = _get_child_item(line, col, 0);
1597 ok(node != NULL, "node == NULL\n");
1598 if(node) {
1599 type = _get_node_type(line, (IUnknown*)node);
1600 ok(type == 3, "type=%d\n", type);
1601 IHTMLDOMNode_Release(node);
1604 IHTMLDOMChildrenCollection_Release(col);
1609 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1610 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1612 IHTMLElement *elem = _get_elem_iface(line, unk);
1613 BSTR html;
1614 HRESULT hres;
1616 hres = IHTMLElement_get_innerHTML(elem, &html);
1617 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1618 if(inner_html)
1619 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1620 else
1621 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1623 IHTMLElement_Release(elem);
1624 SysFreeString(html);
1627 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1628 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1630 IHTMLElement *elem = _get_elem_iface(line, unk);
1631 BSTR html;
1632 HRESULT hres;
1634 html = a2bstr(inner_html);
1635 hres = IHTMLElement_put_innerHTML(elem, html);
1636 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1638 IHTMLElement_Release(elem);
1639 SysFreeString(html);
1642 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1643 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1645 IHTMLElement *elem = _get_elem_iface(line, unk);
1646 BSTR html;
1647 HRESULT hres;
1649 html = a2bstr(outer_html);
1650 hres = IHTMLElement_put_outerHTML(elem, html);
1651 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1653 IHTMLElement_Release(elem);
1654 SysFreeString(html);
1657 #define get_first_child(n) _get_first_child(__LINE__,n)
1658 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1660 IHTMLDOMNode *node = _get_node_iface(line, unk);
1661 IHTMLDOMNode *child = NULL;
1662 HRESULT hres;
1664 hres = IHTMLDOMNode_get_firstChild(node, &child);
1665 IHTMLDOMNode_Release(node);
1666 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1668 return child;
1671 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1672 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1674 IHTMLDOMNode *node = _get_node_iface(line, unk);
1675 VARIANT_BOOL b = 0xdead;
1676 HRESULT hres;
1678 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1679 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1680 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1682 IHTMLDOMNode_Release(node);
1685 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1686 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1688 IHTMLDOMNode *node = _get_node_iface(line, unk);
1689 IHTMLDOMNode *parent;
1690 HRESULT hres;
1692 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1693 IHTMLDOMNode_Release(node);
1694 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1696 return parent;
1699 #define node_get_next(u) _node_get_next(__LINE__,u)
1700 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1702 IHTMLDOMNode *node = _get_node_iface(line, unk);
1703 IHTMLDOMNode *next;
1704 HRESULT hres;
1706 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1707 IHTMLDOMNode_Release(node);
1708 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1710 return next;
1713 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1714 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1716 IHTMLElement *elem = _get_elem_iface(line, unk);
1717 IHTMLElement *parent;
1718 HRESULT hres;
1720 hres = IHTMLElement_get_parentElement(elem, &parent);
1721 IHTMLElement_Release(elem);
1722 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1724 return parent;
1727 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1728 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1730 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1731 VARIANT_BOOL disabled = 100;
1732 HRESULT hres;
1734 if (!elem3) return;
1735 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1736 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1737 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1738 IHTMLElement3_Release(elem3);
1741 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1742 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1744 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1745 HRESULT hres;
1747 if (!elem3) return;
1748 hres = IHTMLElement3_put_disabled(elem3, b);
1749 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1751 IHTMLElement3_Release(elem3);
1752 _test_elem3_get_disabled(line, unk, b);
1755 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1756 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1758 VARIANT_BOOL disabled = 100;
1759 HRESULT hres;
1761 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1762 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1763 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1765 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1768 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
1769 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
1771 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
1772 LONG length;
1773 HRESULT hres;
1775 hres = IHTMLDOMTextNode_get_length(text, &length);
1776 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
1777 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
1778 IHTMLDOMTextNode_Release(text);
1781 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1782 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1784 HRESULT hres;
1786 hres = IHTMLSelectElement_put_disabled(select, b);
1787 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1789 _test_select_get_disabled(line, select, b);
1792 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1793 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1795 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1796 IHTMLTextContainer *txtcont;
1797 LONG l = -1, l2 = -1;
1798 HRESULT hres;
1800 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1801 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1802 IHTMLElement2_Release(elem);
1804 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1805 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1807 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1808 IHTMLTextContainer_Release(txtcont);
1809 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1810 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1812 return l;
1815 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1816 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1818 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1819 IHTMLTextContainer *txtcont;
1820 LONG l = -1, l2 = -1;
1821 HRESULT hres;
1823 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1824 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1825 IHTMLElement2_Release(elem);
1827 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1828 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1830 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1831 IHTMLTextContainer_Release(txtcont);
1832 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1833 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1835 return l;
1838 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1839 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1841 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1842 IHTMLTextContainer *txtcont;
1843 LONG l = -1, l2 = -1;
1844 HRESULT hres;
1846 hres = IHTMLElement2_get_scrollTop(elem, &l);
1847 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1848 IHTMLElement2_Release(elem);
1850 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1851 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1853 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1854 IHTMLTextContainer_Release(txtcont);
1855 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1856 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1858 return l;
1861 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1862 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1864 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1865 IHTMLTextContainer *txtcont;
1866 LONG l = -1, l2 = -1;
1867 HRESULT hres;
1869 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1870 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1872 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1873 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1874 IHTMLElement2_Release(elem);
1876 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1877 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1879 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1880 IHTMLTextContainer_Release(txtcont);
1881 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1882 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1885 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1886 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1888 IHTMLImgElement *img = _get_img_iface(line, unk);
1889 BSTR src;
1890 HRESULT hres;
1892 hres = IHTMLImgElement_get_src(img, &src);
1893 IHTMLImgElement_Release(img);
1894 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1895 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1896 SysFreeString(src);
1899 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1900 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1902 IHTMLImgElement *img = _get_img_iface(line, unk);
1903 BSTR tmp;
1904 HRESULT hres;
1906 tmp = a2bstr(src);
1907 hres = IHTMLImgElement_put_src(img, tmp);
1908 IHTMLImgElement_Release(img);
1909 SysFreeString(tmp);
1910 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1912 _test_img_src(line, unk, src);
1915 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1916 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1918 IHTMLImgElement *img = _get_img_iface(line, unk);
1919 BSTR alt;
1920 HRESULT hres;
1922 hres = IHTMLImgElement_get_alt(img, &alt);
1923 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1924 if(exalt)
1925 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1926 else
1927 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1928 SysFreeString(alt);
1931 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1932 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1934 IHTMLImgElement *img = _get_img_iface(line, unk);
1935 BSTR tmp;
1936 HRESULT hres;
1938 tmp = a2bstr(alt);
1939 hres = IHTMLImgElement_put_alt(img, tmp);
1940 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1941 SysFreeString(tmp);
1943 _test_img_alt(line, unk, alt);
1946 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
1947 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
1949 IHTMLImgElement *img = _get_img_iface(line, unk);
1950 BSTR sName;
1951 HRESULT hres;
1953 hres = IHTMLImgElement_get_name(img, &sName);
1954 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
1955 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
1956 SysFreeString(sName);
1960 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1961 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1963 VARIANT_BOOL disabled = 100;
1964 HRESULT hres;
1966 hres = IHTMLInputElement_get_disabled(input, &disabled);
1967 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1968 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1970 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1973 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1974 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1976 HRESULT hres;
1978 hres = IHTMLInputElement_put_disabled(input, b);
1979 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1981 _test_input_get_disabled(line, input, b);
1984 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1985 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1987 VARIANT_BOOL checked = 100;
1988 HRESULT hres;
1990 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1991 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1992 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1995 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1996 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1998 HRESULT hres;
2000 hres = IHTMLInputElement_put_defaultChecked(input, b);
2001 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2003 _test_input_get_defaultchecked(line, input, b);
2006 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2007 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2009 VARIANT_BOOL checked = 100;
2010 HRESULT hres;
2012 hres = IHTMLInputElement_get_checked(input, &checked);
2013 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2014 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2017 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2018 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2020 HRESULT hres;
2022 hres = IHTMLInputElement_put_checked(input, b);
2023 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2025 _test_input_get_checked(line, input, b);
2028 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2029 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2031 IHTMLInputElement *input;
2032 BSTR bstr;
2033 HRESULT hres;
2035 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2036 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2037 if(FAILED(hres))
2038 return;
2040 hres = IHTMLInputElement_get_value(input, &bstr);
2041 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2042 if(exval)
2043 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2044 else
2045 ok_(__FILE__,line) (!exval, "exval != NULL\n");
2046 SysFreeString(bstr);
2047 IHTMLInputElement_Release(input);
2050 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2051 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2053 IHTMLInputElement *input;
2054 BSTR bstr;
2055 HRESULT hres;
2057 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2058 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2059 if(FAILED(hres))
2060 return;
2062 bstr = a2bstr(val);
2063 hres = IHTMLInputElement_get_value(input, &bstr);
2064 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2065 SysFreeString(bstr);
2066 IHTMLInputElement_Release(input);
2069 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2070 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2072 BSTR src;
2073 HRESULT hres;
2075 hres = IHTMLInputElement_get_src(input, &src);
2076 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2077 if(exsrc)
2078 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2079 else
2080 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2081 SysFreeString(src);
2084 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2085 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2087 BSTR tmp;
2088 HRESULT hres;
2090 tmp = a2bstr(src);
2091 hres = IHTMLInputElement_put_src(input, tmp);
2092 SysFreeString(tmp);
2093 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2095 _test_input_src(line, input, src);
2098 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2099 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2101 IHTMLElement *elem = _get_elem_iface(line, unk);
2102 BSTR class = (void*)0xdeadbeef;
2103 HRESULT hres;
2105 hres = IHTMLElement_get_className(elem, &class);
2106 IHTMLElement_Release(elem);
2107 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2108 if(exclass)
2109 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2110 else
2111 ok_(__FILE__,line) (!class, "class != NULL\n");
2112 SysFreeString(class);
2115 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2116 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2118 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2119 short index = -3;
2120 HRESULT hres;
2122 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2123 IHTMLElement2_Release(elem2);
2124 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2125 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2128 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2129 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2131 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2132 HRESULT hres;
2134 hres = IHTMLElement2_put_tabIndex(elem2, index);
2135 IHTMLElement2_Release(elem2);
2136 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2138 _test_elem_tabindex(line, unk, index);
2141 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2142 static void _test_elem_filters(unsigned line, IUnknown *unk)
2144 IHTMLElement *elem = _get_elem_iface(line, unk);
2145 HRESULT hres;
2146 IHTMLFiltersCollection *filters;
2148 hres = IHTMLElement_get_filters(elem, &filters);
2149 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2150 "get_filters failed: %08x\n", hres);
2151 if(hres == S_OK)
2153 LONG len;
2154 IDispatchEx *dispex;
2156 hres = IHTMLFiltersCollection_get_length(filters, &len);
2157 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2158 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2160 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2161 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2162 "Could not get IDispatchEx interface: %08x\n", hres);
2163 if(SUCCEEDED(hres)) {
2164 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2165 IDispatchEx_Release(dispex);
2168 IHTMLFiltersCollection_Release(filters);
2171 IHTMLElement_Release(elem);
2174 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2175 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2177 IHTMLElement *elem = _get_elem_iface(line, unk);
2178 BSTR tmp;
2179 HRESULT hres;
2181 tmp = class ? a2bstr(class) : NULL;
2182 hres = IHTMLElement_put_className(elem, tmp);
2183 IHTMLElement_Release(elem);
2184 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2185 SysFreeString(tmp);
2187 _test_elem_class(line, unk, class);
2190 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2191 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2193 IHTMLElement *elem = _get_elem_iface(line, unk);
2194 BSTR id = (void*)0xdeadbeef;
2195 HRESULT hres;
2197 hres = IHTMLElement_get_id(elem, &id);
2198 IHTMLElement_Release(elem);
2199 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2201 if(exid)
2202 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2203 else
2204 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2206 SysFreeString(id);
2209 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2210 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2212 IHTMLElement *elem = _get_elem_iface(line, unk);
2213 BSTR tmp = a2bstr(new_id);
2214 HRESULT hres;
2216 hres = IHTMLElement_put_id(elem, tmp);
2217 IHTMLElement_Release(elem);
2218 SysFreeString(tmp);
2219 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2221 _test_elem_id(line, unk, new_id);
2224 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2225 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2227 IHTMLElement *elem = _get_elem_iface(line, unk);
2228 BSTR title;
2229 HRESULT hres;
2231 hres = IHTMLElement_get_title(elem, &title);
2232 IHTMLElement_Release(elem);
2233 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2234 if(extitle)
2235 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2236 else
2237 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2239 SysFreeString(title);
2242 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2243 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2245 IHTMLElement *elem = _get_elem_iface(line, unk);
2246 BSTR tmp;
2247 HRESULT hres;
2249 tmp = a2bstr(title);
2250 hres = IHTMLElement_put_title(elem, tmp);
2251 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2253 IHTMLElement_Release(elem);
2254 SysFreeString(tmp);
2257 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2258 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2260 IHTMLDOMNode *node = _get_node_iface(line, unk);
2261 VARIANT var;
2262 HRESULT hres;
2264 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2265 IHTMLDOMNode_Release(node);
2266 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2268 if(exval) {
2269 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2270 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2271 }else {
2272 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2275 VariantClear(&var);
2278 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2279 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2281 IHTMLDOMNode *node = _get_node_iface(line, unk);
2282 VARIANT var;
2283 HRESULT hres;
2285 V_VT(&var) = VT_BSTR;
2286 V_BSTR(&var) = a2bstr(val);
2288 hres = IHTMLDOMNode_put_nodeValue(node, var);
2289 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2290 IHTMLDOMNode_Release(node);
2291 VariantClear(&var);
2294 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2295 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2297 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2298 LONG l;
2299 HRESULT hres;
2301 hres = IHTMLElement2_get_clientWidth(elem, &l);
2302 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2303 hres = IHTMLElement2_get_clientHeight(elem, &l);
2304 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2306 IHTMLElement2_Release(elem);
2309 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2310 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2312 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2313 LONG l;
2314 HRESULT hres;
2316 hres = IHTMLElement2_get_clientLeft(elem, &l);
2317 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2318 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2320 hres = IHTMLElement2_get_clientTop(elem, &l);
2321 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2322 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2324 IHTMLElement2_Release(elem);
2327 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2328 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2330 IHTMLElement *elem = _get_elem_iface(line, unk);
2331 IHTMLDocument2 *doc;
2332 IDispatch *disp;
2333 HRESULT hres;
2335 disp = NULL;
2336 hres = IHTMLElement_get_document(elem, &disp);
2337 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2338 ok(disp != NULL, "disp == NULL\n");
2340 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2341 IDispatch_Release(disp);
2342 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2344 return doc;
2347 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2348 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2350 IHTMLDocument2 *doc;
2351 HRESULT hres;
2353 doc = NULL;
2354 hres = IHTMLWindow2_get_document(window, &doc);
2355 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2356 ok(doc != NULL, "disp == NULL\n");
2358 return doc;
2361 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2362 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2364 IHTMLElement *elem = NULL;
2365 BSTR tmp;
2366 HRESULT hres;
2368 tmp = a2bstr(tag);
2369 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2370 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2371 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2373 return elem;
2376 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2377 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2379 IHTMLDocument3 *doc3;
2380 IHTMLDOMNode *node = NULL;
2381 BSTR tmp;
2382 HRESULT hres;
2384 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2385 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2387 tmp = a2bstr(text);
2388 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2389 IHTMLDocument3_Release(doc3);
2390 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2391 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2393 return node;
2396 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2397 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2399 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2400 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2401 IHTMLDOMNode *new_child = NULL;
2402 HRESULT hres;
2404 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2405 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2406 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2407 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2409 IHTMLDOMNode_Release(node);
2410 IHTMLDOMNode_Release(child);
2412 return new_child;
2415 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2416 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2418 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2419 IHTMLDOMNode *new_child = NULL;
2420 HRESULT hres;
2422 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2423 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2424 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2425 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2427 IHTMLDOMNode_Release(node);
2429 return new_child;
2432 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2433 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2435 IHTMLDOMNode *node = _get_node_iface(line, unk);
2436 IHTMLDOMNode *new_node = NULL;
2437 HRESULT hres;
2439 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2440 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2441 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2442 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2444 IHTMLDOMNode_Release(node);
2445 IHTMLDOMNode_Release(new_node);
2448 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2449 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2451 BSTR title = NULL;
2452 HRESULT hres;
2454 hres = IHTMLDocument2_get_title(doc, &title);
2455 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2456 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2457 SysFreeString(title);
2460 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2461 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2463 BSTR tmp;
2464 HRESULT hres;
2466 tmp = a2bstr(title);
2467 hres = IHTMLDocument2_put_title(doc, tmp);
2468 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2469 SysFreeString(tmp);
2472 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2473 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2475 HRESULT hres;
2476 DISPID dispid;
2478 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2479 LOCALE_USER_DEFAULT, &dispid);
2480 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2481 if(hres == S_OK)
2483 DISPPARAMS params = {NULL,NULL,0,0};
2484 DISPID dispidNamed = DISPID_PROPERTYPUT;
2485 VARIANT ret;
2486 VARIANT vDefault;
2487 VARIANTARG arg;
2489 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2490 DISPATCH_PROPERTYGET, &params, &vDefault, NULL, NULL);
2491 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2493 params.cArgs = 1;
2494 params.cNamedArgs = 1;
2495 params.rgdispidNamedArgs = &dispidNamed;
2496 V_VT(&arg) = VT_BSTR;
2497 V_BSTR(&arg) = a2bstr("none");
2498 params.rgvarg = &arg;
2499 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2500 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2501 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2502 VariantClear(&arg);
2504 V_VT(&arg) = VT_BSTR;
2505 V_BSTR(&arg) = a2bstr("dotted");
2506 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2507 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2508 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2509 VariantClear(&arg);
2511 V_VT(&arg) = VT_BSTR;
2512 V_BSTR(&arg) = a2bstr("dashed");
2513 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2514 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2515 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2516 VariantClear(&arg);
2518 V_VT(&arg) = VT_BSTR;
2519 V_BSTR(&arg) = a2bstr("solid");
2520 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2521 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2522 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2523 VariantClear(&arg);
2525 V_VT(&arg) = VT_BSTR;
2526 V_BSTR(&arg) = a2bstr("double");
2527 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2528 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2529 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2530 VariantClear(&arg);
2532 V_VT(&arg) = VT_BSTR;
2533 V_BSTR(&arg) = a2bstr("groove");
2534 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2535 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2536 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2537 VariantClear(&arg);
2539 V_VT(&arg) = VT_BSTR;
2540 V_BSTR(&arg) = a2bstr("ridge");
2541 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2542 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2543 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2544 VariantClear(&arg);
2546 V_VT(&arg) = VT_BSTR;
2547 V_BSTR(&arg) = a2bstr("inset");
2548 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2549 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2550 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2551 VariantClear(&arg);
2553 V_VT(&arg) = VT_BSTR;
2554 V_BSTR(&arg) = a2bstr("outset");
2555 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2556 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2557 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2558 VariantClear(&arg);
2560 V_VT(&arg) = VT_BSTR;
2561 V_BSTR(&arg) = a2bstr("invalid");
2562 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2563 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2564 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2565 VariantClear(&arg);
2567 params.rgvarg = &vDefault;
2568 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2569 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2570 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2574 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2575 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2577 BSTR text = (void*)0xdeadbeef;
2578 HRESULT hres;
2580 hres = IHTMLStyle_get_cssText(style, &text);
2581 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2582 if(extext)
2583 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2584 else
2585 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2587 SysFreeString(text);
2590 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2591 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2593 BSTR tmp;
2594 HRESULT hres;
2596 tmp = a2bstr(text);
2597 hres = IHTMLStyle_put_cssText(style, tmp);
2598 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2599 SysFreeString(tmp);
2602 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2603 const elem_type_t *elem_types, LONG len)
2605 IDispatch *disp;
2606 VARIANT name, index;
2607 DWORD i;
2608 HRESULT hres;
2610 V_VT(&index) = VT_EMPTY;
2611 V_VT(&name) = VT_BSTR;
2612 V_BSTR(&name) = a2bstr(n);
2614 hres = IHTMLElementCollection_item(col, name, index, &disp);
2615 ok(hres == S_OK, "item failed: %08x\n", hres);
2617 test_elem_collection((IUnknown*)disp, elem_types, len);
2618 IDispatch_Release(disp);
2619 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2620 if(hres != S_OK)
2621 goto cleanup;
2623 V_VT(&index) = VT_I4;
2625 for(i=0; i<len; i++) {
2626 V_I4(&index) = i;
2627 disp = (void*)0xdeadbeef;
2628 hres = IHTMLElementCollection_item(col, name, index, &disp);
2629 ok(hres == S_OK, "item failed: %08x\n", hres);
2630 ok(disp != NULL, "disp == NULL\n");
2631 if(FAILED(hres) || !disp)
2632 continue;
2634 test_elem_type((IUnknown*)disp, elem_types[i]);
2636 IDispatch_Release(disp);
2639 V_I4(&index) = len;
2640 disp = (void*)0xdeadbeef;
2641 hres = IHTMLElementCollection_item(col, name, index, &disp);
2642 ok(hres == S_OK, "item failed: %08x\n", hres);
2643 ok(disp == NULL, "disp != NULL\n");
2645 V_I4(&index) = -1;
2646 disp = (void*)0xdeadbeef;
2647 hres = IHTMLElementCollection_item(col, name, index, &disp);
2648 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2649 ok(disp == NULL, "disp != NULL\n");
2651 cleanup:
2652 SysFreeString(V_BSTR(&name));
2655 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2657 IHTMLElementCollection *col;
2658 IHTMLElement *elem;
2659 IDispatch *disp = (void*)0xdeadbeef;
2660 VARIANT name, index;
2661 HRESULT hres;
2663 hres = IHTMLDocument2_get_all(doc, &col);
2664 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2665 ok(col != NULL, "col == NULL\n");
2666 if(FAILED(hres) || !col)
2667 return NULL;
2669 V_VT(&index) = VT_EMPTY;
2670 V_VT(&name) = VT_BSTR;
2671 V_BSTR(&name) = a2bstr(id);
2673 hres = IHTMLElementCollection_item(col, name, index, &disp);
2674 IHTMLElementCollection_Release(col);
2675 SysFreeString(V_BSTR(&name));
2676 ok(hres == S_OK, "item failed: %08x\n", hres);
2677 if(!expect_success) {
2678 ok(disp == NULL, "disp != NULL\n");
2679 return NULL;
2682 ok(disp != NULL, "disp == NULL\n");
2683 if(!disp)
2684 return NULL;
2686 elem = get_elem_iface((IUnknown*)disp);
2687 IDispatch_Release(disp);
2689 return elem;
2692 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2694 IHTMLDocument3 *doc3;
2695 IHTMLElement *elem;
2696 BSTR tmp;
2697 HRESULT hres;
2699 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2700 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2702 tmp = a2bstr(id);
2703 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2704 SysFreeString(tmp);
2705 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2707 IHTMLDocument3_Release(doc3);
2709 return elem;
2712 static void test_select_elem(IHTMLSelectElement *select)
2714 test_select_type(select, "select-one");
2715 test_select_length(select, 2);
2716 test_select_selidx(select, 0);
2717 test_select_put_selidx(select, 1);
2719 test_select_set_value(select, "val1");
2720 test_select_value(select, "val1");
2722 test_select_get_disabled(select, VARIANT_FALSE);
2723 test_select_set_disabled(select, VARIANT_TRUE);
2724 test_select_set_disabled(select, VARIANT_FALSE);
2727 static void test_create_option_elem(IHTMLDocument2 *doc)
2729 IHTMLOptionElement *option;
2731 option = create_option_elem(doc, "test text", "test value");
2733 test_option_put_text(option, "new text");
2734 test_option_put_value(option, "new value");
2736 IHTMLOptionElement_Release(option);
2739 static void test_create_img_elem(IHTMLDocument2 *doc)
2741 IHTMLImgElement *img;
2743 img = create_img_elem(doc, 10, 15);
2745 if(img){
2746 test_img_put_width(img, 5);
2747 test_img_put_height(img, 20);
2749 IHTMLImgElement_Release(img);
2750 img = NULL;
2753 img = create_img_elem(doc, -1, -1);
2755 if(img){
2756 test_img_put_width(img, 5);
2757 test_img_put_height(img, 20);
2759 IHTMLImgElement_Release(img);
2763 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2765 IHTMLBodyElement *body;
2766 IHTMLTxtRange *range;
2767 IHTMLElement *elem;
2768 HRESULT hres;
2770 hres = IHTMLDocument2_get_body(doc, &elem);
2771 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2773 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2774 IHTMLElement_Release(elem);
2776 hres = IHTMLBodyElement_createTextRange(body, &range);
2777 IHTMLBodyElement_Release(body);
2778 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2780 return range;
2783 static void test_txtrange(IHTMLDocument2 *doc)
2785 IHTMLTxtRange *body_range, *range, *range2;
2786 IHTMLSelectionObject *selection;
2787 IDispatch *disp_range;
2788 HRESULT hres;
2790 body_range = test_create_body_range(doc);
2792 test_range_text(body_range, "test abc 123\r\nit's text");
2794 hres = IHTMLTxtRange_duplicate(body_range, &range);
2795 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2797 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2798 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2799 test_range_isequal(range, range2, VARIANT_TRUE);
2801 test_range_text(range, "test abc 123\r\nit's text");
2802 test_range_text(body_range, "test abc 123\r\nit's text");
2804 test_range_collapse(range, TRUE);
2805 test_range_isequal(range, range2, VARIANT_FALSE);
2806 test_range_inrange(range, range2, VARIANT_FALSE);
2807 test_range_inrange(range2, range, VARIANT_TRUE);
2808 IHTMLTxtRange_Release(range2);
2810 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2811 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2812 test_range_move(range, characterW, 2, 2);
2813 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2815 test_range_collapse(range, FALSE);
2816 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2818 test_range_collapse(range, FALSE);
2819 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2820 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2821 test_range_move(range, characterW, 2, 2);
2822 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2823 test_range_moveend(range, characterW, -5, -5);
2824 test_range_text(range, NULL);
2825 test_range_moveend(range, characterW, 3, 3);
2826 test_range_text(range, "c 1");
2827 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2828 test_range_collapse(range, TRUE);
2829 test_range_move(range, characterW, 4, 4);
2830 test_range_moveend(range, characterW, 1, 1);
2831 test_range_text(range, " ");
2832 test_range_move(range, wordW, 1, 1);
2833 test_range_moveend(range, characterW, 2, 2);
2834 test_range_text(range, "ab");
2836 IHTMLTxtRange_Release(range);
2838 hres = IHTMLTxtRange_duplicate(body_range, &range);
2839 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2841 test_range_text(range, "test abc 123\r\nit's text");
2842 test_range_move(range, characterW, 3, 3);
2843 test_range_moveend(range, characterW, 1, 1);
2844 test_range_text(range, "t");
2845 test_range_moveend(range, characterW, 3, 3);
2846 test_range_text(range, "t ab");
2847 test_range_moveend(range, characterW, -2, -2);
2848 test_range_text(range, "t ");
2849 test_range_move(range, characterW, 6, 6);
2850 test_range_moveend(range, characterW, 3, 3);
2851 test_range_text(range, "123");
2852 test_range_moveend(range, characterW, 2, 2);
2853 test_range_text(range, "123\r\ni");
2855 IHTMLTxtRange_Release(range);
2857 hres = IHTMLTxtRange_duplicate(body_range, &range);
2858 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2860 test_range_move(range, wordW, 1, 1);
2861 test_range_moveend(range, characterW, 2, 2);
2862 test_range_text(range, "ab");
2864 test_range_move(range, characterW, -2, -2);
2865 test_range_moveend(range, characterW, 2, 2);
2866 test_range_text(range, "t ");
2868 test_range_move(range, wordW, 3, 3);
2869 test_range_move(range, wordW, -2, -2);
2870 test_range_moveend(range, characterW, 2, 2);
2871 test_range_text(range, "ab");
2873 test_range_move(range, characterW, -6, -5);
2874 test_range_moveend(range, characterW, -1, 0);
2875 test_range_moveend(range, characterW, -6, 0);
2876 test_range_move(range, characterW, 2, 2);
2877 test_range_moveend(range, characterW, 2, 2);
2878 test_range_text(range, "st");
2879 test_range_moveend(range, characterW, -6, -4);
2880 test_range_moveend(range, characterW, 2, 2);
2882 IHTMLTxtRange_Release(range);
2884 hres = IHTMLTxtRange_duplicate(body_range, &range);
2885 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2887 test_range_move(range, wordW, 2, 2);
2888 test_range_moveend(range, characterW, 2, 2);
2889 test_range_text(range, "12");
2891 test_range_move(range, characterW, 15, 14);
2892 test_range_move(range, characterW, -2, -2);
2893 test_range_moveend(range, characterW, 3, 2);
2894 test_range_text(range, "t");
2895 test_range_moveend(range, characterW, -1, -1);
2896 test_range_text(range, "t");
2897 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2898 test_range_move(range, characterW, -2, -2);
2899 test_range_moveend(range, characterW, 2, 2);
2900 test_range_text(range, "s ");
2901 test_range_move(range, characterW, 100, 7);
2902 test_range_move(range, wordW, 1, 0);
2903 test_range_move(range, characterW, -2, -2);
2904 test_range_moveend(range, characterW, 3, 2);
2905 test_range_text(range, "t");
2907 IHTMLTxtRange_Release(range);
2909 hres = IHTMLTxtRange_duplicate(body_range, &range);
2910 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2912 test_range_collapse(range, TRUE);
2913 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2914 test_range_put_text(range, "word");
2915 test_range_text(body_range, "wordabc 123\r\nit's text");
2916 test_range_text(range, NULL);
2917 test_range_moveend(range, characterW, 3, 3);
2918 test_range_text(range, "abc");
2919 test_range_movestart(range, characterW, -2, -2);
2920 test_range_text(range, "rdabc");
2921 test_range_movestart(range, characterW, 3, 3);
2922 test_range_text(range, "bc");
2923 test_range_movestart(range, characterW, 4, 4);
2924 test_range_text(range, NULL);
2925 test_range_movestart(range, characterW, -3, -3);
2926 test_range_text(range, "c 1");
2927 test_range_movestart(range, characterW, -7, -6);
2928 test_range_text(range, "wordabc 1");
2929 test_range_movestart(range, characterW, 100, 22);
2930 test_range_text(range, NULL);
2932 IHTMLTxtRange_Release(range);
2933 IHTMLTxtRange_Release(body_range);
2935 hres = IHTMLDocument2_get_selection(doc, &selection);
2936 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2938 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2939 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2940 IHTMLSelectionObject_Release(selection);
2942 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2943 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2944 IDispatch_Release(disp_range);
2946 test_range_text(range, NULL);
2947 test_range_moveend(range, characterW, 3, 3);
2948 test_range_text(range, "wor");
2949 test_range_parent(range, ET_BODY);
2950 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2951 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2952 test_range_move(range, characterW, 3, 3);
2953 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2954 test_range_moveend(range, characterW, -4, -4);
2955 test_range_put_text(range, "abc def ");
2956 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2957 test_range_move(range, wordW, 1, 1);
2958 test_range_movestart(range, characterW, -1, -1);
2959 test_range_text(range, " ");
2960 test_range_move(range, wordW, 1, 1);
2961 test_range_moveend(range, characterW, 3, 3);
2962 test_range_text(range, "def");
2963 test_range_put_text(range, "xyz");
2964 test_range_moveend(range, characterW, 1, 1);
2965 test_range_move(range, wordW, 1, 1);
2966 test_range_moveend(range, characterW, 2, 2);
2967 test_range_text(range, "ab");
2969 IHTMLTxtRange_Release(range);
2972 static void test_txtrange2(IHTMLDocument2 *doc)
2974 IHTMLTxtRange *range;
2976 range = test_create_body_range(doc);
2978 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2979 test_range_move(range, characterW, 5, 5);
2980 test_range_moveend(range, characterW, 1, 1);
2981 test_range_text(range, "2");
2982 test_range_move(range, characterW, -3, -3);
2983 test_range_moveend(range, characterW, 3, 3);
2984 test_range_text(range, "c\r\n\r\n1");
2985 test_range_collapse(range, VARIANT_FALSE);
2986 test_range_moveend(range, characterW, 4, 4);
2987 test_range_text(range, "23");
2988 test_range_moveend(range, characterW, 1, 1);
2989 test_range_text(range, "23\r\n\r\n\r\nd");
2990 test_range_moveend(range, characterW, -1, -1);
2991 test_range_text(range, "23");
2992 test_range_moveend(range, characterW, -1, -1);
2993 test_range_text(range, "23");
2994 test_range_moveend(range, characterW, -2, -2);
2995 test_range_text(range, "2");
2997 IHTMLTxtRange_Release(range);
3000 static void test_compatmode(IHTMLDocument2 *doc)
3002 IHTMLDocument5 *doc5;
3003 BSTR mode;
3004 HRESULT hres;
3006 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3007 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3008 if(FAILED(hres))
3009 return;
3011 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3012 IHTMLDocument5_Release(doc5);
3013 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3014 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3015 SysFreeString(mode);
3018 static void test_location(IHTMLDocument2 *doc)
3020 IHTMLLocation *location, *location2;
3021 IHTMLWindow2 *window;
3022 BSTR str;
3023 ULONG ref;
3024 HRESULT hres;
3026 hres = IHTMLDocument2_get_location(doc, &location);
3027 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3029 hres = IHTMLDocument2_get_location(doc, &location2);
3030 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3032 ok(location == location2, "location != location2\n");
3033 IHTMLLocation_Release(location2);
3035 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3036 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3038 hres = IHTMLWindow2_get_location(window, &location2);
3039 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3040 ok(location == location2, "location != location2\n");
3041 IHTMLLocation_Release(location2);
3043 test_ifaces((IUnknown*)location, location_iids);
3044 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3046 hres = IHTMLLocation_get_pathname(location, &str);
3047 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3048 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3050 hres = IHTMLLocation_get_href(location, NULL);
3051 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3053 hres = IHTMLLocation_get_href(location, &str);
3054 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3055 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3057 ref = IHTMLLocation_Release(location);
3058 ok(!ref, "location chould be destroyed here\n");
3061 static void test_navigator(IHTMLDocument2 *doc)
3063 IHTMLWindow2 *window;
3064 IOmNavigator *navigator, *navigator2;
3065 char buf[512];
3066 DWORD size;
3067 ULONG ref;
3068 BSTR bstr;
3069 HRESULT hres;
3071 static const WCHAR v40[] = {'4','.','0'};
3073 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3074 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3076 hres = IHTMLWindow2_get_navigator(window, &navigator);
3077 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3078 ok(navigator != NULL, "navigator == NULL\n");
3079 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3081 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3082 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3083 ok(navigator != navigator2, "navigator2 != navihgator\n");
3085 IHTMLWindow2_Release(window);
3086 IOmNavigator_Release(navigator2);
3088 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3089 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3090 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3091 SysFreeString(bstr);
3093 bstr = NULL;
3094 hres = IOmNavigator_get_appName(navigator, &bstr);
3095 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3096 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3097 SysFreeString(bstr);
3099 bstr = NULL;
3100 hres = IOmNavigator_get_platform(navigator, &bstr);
3101 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3102 #ifdef _WIN64
3103 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3104 #else
3105 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3106 #endif
3107 SysFreeString(bstr);
3109 bstr = NULL;
3110 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3111 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3112 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3113 SysFreeString(bstr);
3115 hres = IOmNavigator_toString(navigator, NULL);
3116 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3118 bstr = NULL;
3119 hres = IOmNavigator_toString(navigator, &bstr);
3120 ok(hres == S_OK, "toString failed: %08x\n", hres);
3121 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3122 SysFreeString(bstr);
3124 size = sizeof(buf);
3125 hres = ObtainUserAgentString(0, buf, &size);
3126 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3128 bstr = NULL;
3129 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3130 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3131 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3132 SysFreeString(bstr);
3134 ref = IOmNavigator_Release(navigator);
3135 ok(!ref, "navigator should be destroyed here\n");
3138 static void test_screen(IHTMLWindow2 *window)
3140 IHTMLScreen *screen, *screen2;
3141 IDispatchEx *dispex;
3142 LONG l, exl;
3143 HDC hdc;
3144 HRESULT hres;
3146 static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
3148 screen = NULL;
3149 hres = IHTMLWindow2_get_screen(window, &screen);
3150 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3151 ok(screen != NULL, "screen == NULL\n");
3153 screen2 = NULL;
3154 hres = IHTMLWindow2_get_screen(window, &screen2);
3155 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3156 ok(screen2 != NULL, "screen == NULL\n");
3157 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3158 IHTMLScreen_Release(screen2);
3160 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3161 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3162 if(SUCCEEDED(hres)) {
3163 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3164 IDispatchEx_Release(dispex);
3167 hdc = CreateICW(displayW, NULL, NULL, NULL);
3169 exl = GetDeviceCaps(hdc, HORZRES);
3170 l = 0xdeadbeef;
3171 hres = IHTMLScreen_get_width(screen, &l);
3172 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3173 ok(l == exl, "width = %d, expected %d\n", l, exl);
3175 exl = GetDeviceCaps(hdc, VERTRES);
3176 l = 0xdeadbeef;
3177 hres = IHTMLScreen_get_height(screen, &l);
3178 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3179 ok(l == exl, "height = %d, expected %d\n", l, exl);
3181 exl = GetDeviceCaps(hdc, BITSPIXEL);
3182 l = 0xdeadbeef;
3183 hres = IHTMLScreen_get_colorDepth(screen, &l);
3184 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3185 ok(l == exl, "height = %d, expected %d\n", l, exl);
3187 DeleteObject(hdc);
3189 IHTMLScreen_Release(screen);
3192 static void test_current_style(IHTMLCurrentStyle *current_style)
3194 BSTR str;
3195 HRESULT hres;
3196 VARIANT v;
3198 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3199 test_ifaces((IUnknown*)current_style, cstyle_iids);
3201 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3202 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3203 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3204 SysFreeString(str);
3206 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3207 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3208 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3209 SysFreeString(str);
3211 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3212 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3213 SysFreeString(str);
3215 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3216 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3217 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3218 SysFreeString(str);
3220 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3221 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3222 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3223 SysFreeString(str);
3225 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3226 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3227 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3228 SysFreeString(str);
3230 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3231 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3232 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3233 SysFreeString(str);
3235 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3236 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3237 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3238 SysFreeString(str);
3240 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3241 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3242 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3243 SysFreeString(str);
3245 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3246 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3247 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3248 SysFreeString(str);
3250 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3251 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3252 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3253 SysFreeString(str);
3255 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3256 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3257 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3258 SysFreeString(str);
3260 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3261 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3262 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3263 SysFreeString(str);
3265 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3266 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3267 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3268 SysFreeString(str);
3270 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3271 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3272 SysFreeString(str);
3274 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3275 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3276 SysFreeString(str);
3278 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3279 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3280 SysFreeString(str);
3282 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3283 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3284 SysFreeString(str);
3286 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3287 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3288 SysFreeString(str);
3290 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3291 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3292 SysFreeString(str);
3294 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3295 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3296 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3297 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3298 VariantClear(&v);
3300 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3301 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3302 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3303 VariantClear(&v);
3305 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3306 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3307 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3308 VariantClear(&v);
3310 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3311 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3312 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3313 VariantClear(&v);
3315 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3316 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3317 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3318 VariantClear(&v);
3320 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3321 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3322 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3323 VariantClear(&v);
3325 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3326 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3327 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3328 VariantClear(&v);
3330 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3331 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3332 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3333 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3334 VariantClear(&v);
3336 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3337 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3338 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3339 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3340 VariantClear(&v);
3342 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3343 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3344 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3345 VariantClear(&v);
3347 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3348 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3349 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3350 VariantClear(&v);
3352 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3353 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3354 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3355 VariantClear(&v);
3357 V_BSTR(&v) = NULL;
3358 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3359 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3360 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3361 VariantClear(&v);
3363 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3364 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3365 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3366 VariantClear(&v);
3368 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3369 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3370 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3371 VariantClear(&v);
3373 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3374 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3375 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3376 VariantClear(&v);
3378 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3379 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3380 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3381 VariantClear(&v);
3383 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3384 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3385 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3386 VariantClear(&v);
3388 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3389 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3390 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3391 VariantClear(&v);
3393 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3394 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3395 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3396 VariantClear(&v);
3398 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3399 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3400 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3401 VariantClear(&v);
3403 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3404 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3405 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3406 VariantClear(&v);
3408 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3409 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3410 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3411 VariantClear(&v);
3413 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3414 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3415 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3416 VariantClear(&v);
3418 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3419 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3420 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3421 VariantClear(&v);
3423 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3424 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3425 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3426 VariantClear(&v);
3428 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3429 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3430 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3431 VariantClear(&v);
3433 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3434 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3435 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3436 VariantClear(&v);
3438 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3439 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3440 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3441 VariantClear(&v);
3443 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3444 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3445 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3446 VariantClear(&v);
3448 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3449 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3450 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3451 VariantClear(&v);
3454 static void test_style2(IHTMLStyle2 *style2)
3456 VARIANT v;
3457 BSTR str;
3458 HRESULT hres;
3460 str = (void*)0xdeadbeef;
3461 hres = IHTMLStyle2_get_position(style2, &str);
3462 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3463 ok(!str, "str != NULL\n");
3465 str = a2bstr("absolute");
3466 hres = IHTMLStyle2_put_position(style2, str);
3467 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3468 SysFreeString(str);
3470 str = NULL;
3471 hres = IHTMLStyle2_get_position(style2, &str);
3472 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3473 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3474 SysFreeString(str);
3476 /* Test right */
3477 V_VT(&v) = VT_EMPTY;
3478 hres = IHTMLStyle2_get_right(style2, &v);
3479 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3480 ok(V_VT(&v) == VT_BSTR, "V_VT(right)=%d\n", V_VT(&v));
3481 ok(!V_BSTR(&v), "V_BSTR(right) != NULL\n");
3482 VariantClear(&v);
3484 V_VT(&v) = VT_BSTR;
3485 V_BSTR(&v) = a2bstr("3px");
3486 hres = IHTMLStyle2_put_right(style2, v);
3487 ok(hres == S_OK, "put_right failed: %08x\n", hres);
3488 VariantClear(&v);
3490 V_VT(&v) = VT_EMPTY;
3491 hres = IHTMLStyle2_get_right(style2, &v);
3492 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3493 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3494 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3495 VariantClear(&v);
3498 static void test_style3(IHTMLStyle3 *style3)
3500 BSTR str;
3501 HRESULT hres;
3503 str = (void*)0xdeadbeef;
3504 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3505 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3506 ok(!str, "str != NULL\n");
3508 str = a2bstr("break-word");
3509 hres = IHTMLStyle3_put_wordWrap(style3, str);
3510 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3511 SysFreeString(str);
3513 str = NULL;
3514 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3515 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3516 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3517 SysFreeString(str);
3520 static void test_style4(IHTMLStyle4 *style4)
3522 HRESULT hres;
3523 VARIANT v;
3524 VARIANT vdefault;
3526 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3527 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3529 V_VT(&v) = VT_BSTR;
3530 V_BSTR(&v) = a2bstr("10px");
3531 hres = IHTMLStyle4_put_minHeight(style4, v);
3532 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3533 VariantClear(&v);
3535 hres = IHTMLStyle4_get_minHeight(style4, &v);
3536 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3537 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3538 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3540 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3541 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3542 VariantClear(&vdefault);
3545 static void test_default_style(IHTMLStyle *style)
3547 IHTMLStyle2 *style2;
3548 IHTMLStyle3 *style3;
3549 IHTMLStyle4 *style4;
3550 VARIANT_BOOL b;
3551 VARIANT v;
3552 BSTR str;
3553 HRESULT hres;
3554 float f;
3555 BSTR sOverflowDefault;
3556 BSTR sDefault;
3557 VARIANT vDefault;
3559 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3560 test_ifaces((IUnknown*)style, style_iids);
3562 test_style_csstext(style, NULL);
3564 hres = IHTMLStyle_get_position(style, &str);
3565 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3566 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3568 V_VT(&v) = VT_NULL;
3569 hres = IHTMLStyle_get_marginRight(style, &v);
3570 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3571 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3572 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3574 V_VT(&v) = VT_NULL;
3575 hres = IHTMLStyle_get_marginLeft(style, &v);
3576 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3577 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3578 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3580 str = (void*)0xdeadbeef;
3581 hres = IHTMLStyle_get_fontFamily(style, &str);
3582 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3583 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3585 str = (void*)0xdeadbeef;
3586 hres = IHTMLStyle_get_fontWeight(style, &str);
3587 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3588 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3590 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3591 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3593 str = a2bstr("test");
3594 hres = IHTMLStyle_put_fontWeight(style, str);
3595 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3596 SysFreeString(str);
3598 str = a2bstr("bold");
3599 hres = IHTMLStyle_put_fontWeight(style, str);
3600 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3601 SysFreeString(str);
3603 str = a2bstr("bolder");
3604 hres = IHTMLStyle_put_fontWeight(style, str);
3605 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3606 SysFreeString(str);
3608 str = a2bstr("lighter");
3609 hres = IHTMLStyle_put_fontWeight(style, str);
3610 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3611 SysFreeString(str);
3613 str = a2bstr("100");
3614 hres = IHTMLStyle_put_fontWeight(style, str);
3615 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3616 SysFreeString(str);
3618 str = a2bstr("200");
3619 hres = IHTMLStyle_put_fontWeight(style, str);
3620 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3621 SysFreeString(str);
3623 str = a2bstr("300");
3624 hres = IHTMLStyle_put_fontWeight(style, str);
3625 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3626 SysFreeString(str);
3628 str = a2bstr("400");
3629 hres = IHTMLStyle_put_fontWeight(style, str);
3630 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3631 SysFreeString(str);
3633 str = a2bstr("500");
3634 hres = IHTMLStyle_put_fontWeight(style, str);
3635 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3636 SysFreeString(str);
3638 str = a2bstr("600");
3639 hres = IHTMLStyle_put_fontWeight(style, str);
3640 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3641 SysFreeString(str);
3643 str = a2bstr("700");
3644 hres = IHTMLStyle_put_fontWeight(style, str);
3645 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3646 SysFreeString(str);
3648 str = a2bstr("800");
3649 hres = IHTMLStyle_put_fontWeight(style, str);
3650 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3651 SysFreeString(str);
3653 str = a2bstr("900");
3654 hres = IHTMLStyle_put_fontWeight(style, str);
3655 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3656 SysFreeString(str);
3658 hres = IHTMLStyle_get_fontWeight(style, &str);
3659 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3660 ok(!strcmp_wa(str, "900"), "str != style900\n");
3661 SysFreeString(str);
3663 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3664 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3665 SysFreeString(sDefault);
3667 /* font Variant */
3668 hres = IHTMLStyle_get_fontVariant(style, NULL);
3669 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3671 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3672 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3674 str = a2bstr("test");
3675 hres = IHTMLStyle_put_fontVariant(style, str);
3676 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3677 SysFreeString(str);
3679 str = a2bstr("small-caps");
3680 hres = IHTMLStyle_put_fontVariant(style, str);
3681 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3682 SysFreeString(str);
3684 str = a2bstr("normal");
3685 hres = IHTMLStyle_put_fontVariant(style, str);
3686 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3687 SysFreeString(str);
3689 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3690 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3691 SysFreeString(sDefault);
3693 str = (void*)0xdeadbeef;
3694 hres = IHTMLStyle_get_display(style, &str);
3695 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3696 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3698 str = (void*)0xdeadbeef;
3699 hres = IHTMLStyle_get_visibility(style, &str);
3700 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3701 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3703 V_VT(&v) = VT_NULL;
3704 hres = IHTMLStyle_get_fontSize(style, &v);
3705 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3706 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3707 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3709 V_VT(&v) = VT_NULL;
3710 hres = IHTMLStyle_get_color(style, &v);
3711 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3712 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3713 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3715 b = 0xfefe;
3716 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3717 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3718 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3720 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3721 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3722 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3724 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3725 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3726 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3728 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3729 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3731 b = 0xfefe;
3732 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3733 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3734 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3736 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3737 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3738 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3740 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3741 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3742 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3744 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3745 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3747 b = 0xfefe;
3748 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3749 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3750 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3752 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3753 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3754 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3756 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3757 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3758 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3760 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3761 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3763 b = 0xfefe;
3764 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3765 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3766 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3768 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3769 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3770 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3772 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3773 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3774 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3776 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3777 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3779 b = 0xfefe;
3780 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3781 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3782 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3784 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3785 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3786 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3788 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3789 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3790 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3792 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3793 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3795 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3796 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3798 str = a2bstr("invalid");
3799 hres = IHTMLStyle_put_textDecoration(style, str);
3800 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3801 SysFreeString(str);
3803 str = a2bstr("none");
3804 hres = IHTMLStyle_put_textDecoration(style, str);
3805 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3806 SysFreeString(str);
3808 str = a2bstr("underline");
3809 hres = IHTMLStyle_put_textDecoration(style, str);
3810 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3811 SysFreeString(str);
3813 str = a2bstr("overline");
3814 hres = IHTMLStyle_put_textDecoration(style, str);
3815 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3816 SysFreeString(str);
3818 str = a2bstr("line-through");
3819 hres = IHTMLStyle_put_textDecoration(style, str);
3820 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3821 SysFreeString(str);
3823 str = a2bstr("blink");
3824 hres = IHTMLStyle_put_textDecoration(style, str);
3825 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3826 SysFreeString(str);
3828 hres = IHTMLStyle_get_textDecoration(style, &str);
3829 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3830 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3831 SysFreeString(str);
3833 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3834 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3835 SysFreeString(sDefault);
3837 hres = IHTMLStyle_get_posWidth(style, NULL);
3838 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3840 hres = IHTMLStyle_get_posWidth(style, &f);
3841 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3842 ok(f == 0.0f, "f = %f\n", f);
3844 V_VT(&v) = VT_EMPTY;
3845 hres = IHTMLStyle_get_width(style, &v);
3846 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3847 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3848 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3850 hres = IHTMLStyle_put_posWidth(style, 2.2);
3851 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3853 hres = IHTMLStyle_get_posWidth(style, &f);
3854 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3855 ok(f == 2.0f ||
3856 f == 2.2f, /* IE8 */
3857 "f = %f\n", f);
3859 V_VT(&v) = VT_BSTR;
3860 V_BSTR(&v) = a2bstr("auto");
3861 hres = IHTMLStyle_put_width(style, v);
3862 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3863 VariantClear(&v);
3865 V_VT(&v) = VT_EMPTY;
3866 hres = IHTMLStyle_get_width(style, &v);
3867 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3868 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3869 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3870 VariantClear(&v);
3872 V_VT(&v) = VT_I4;
3873 V_I4(&v) = 100;
3874 hres = IHTMLStyle_put_width(style, v);
3875 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3877 V_VT(&v) = VT_EMPTY;
3878 hres = IHTMLStyle_get_width(style, &v);
3879 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3880 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3881 ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3882 VariantClear(&v);
3884 /* margin tests */
3885 str = (void*)0xdeadbeef;
3886 hres = IHTMLStyle_get_margin(style, &str);
3887 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3888 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3890 str = a2bstr("1");
3891 hres = IHTMLStyle_put_margin(style, str);
3892 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3893 SysFreeString(str);
3895 hres = IHTMLStyle_get_margin(style, &str);
3896 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3897 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3899 hres = IHTMLStyle_put_margin(style, NULL);
3900 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3902 str = (void*)0xdeadbeef;
3903 hres = IHTMLStyle_get_marginTop(style, &v);
3904 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3905 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
3906 ok(!V_BSTR(&v), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3908 V_VT(&v) = VT_BSTR;
3909 V_BSTR(&v) = a2bstr("6px");
3910 hres = IHTMLStyle_put_marginTop(style, v);
3911 SysFreeString(V_BSTR(&v));
3912 ok(hres == S_OK, "put_marginTop failed: %08x\n", hres);
3914 str = (void*)0xdeadbeef;
3915 hres = IHTMLStyle_get_marginTop(style, &v);
3916 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3917 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
3918 ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3920 str = NULL;
3921 hres = IHTMLStyle_get_border(style, &str);
3922 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3923 ok(!str || !*str, "str is not empty\n");
3924 SysFreeString(str);
3926 str = a2bstr("1px");
3927 hres = IHTMLStyle_put_border(style, str);
3928 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3929 SysFreeString(str);
3931 V_VT(&v) = VT_EMPTY;
3932 hres = IHTMLStyle_get_left(style, &v);
3933 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3934 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3935 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3936 VariantClear(&v);
3938 /* Test posLeft */
3939 hres = IHTMLStyle_get_posLeft(style, NULL);
3940 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3942 f = 1.0f;
3943 hres = IHTMLStyle_get_posLeft(style, &f);
3944 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3945 ok(f == 0.0, "expected 0.0 got %f\n", f);
3947 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3948 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3950 hres = IHTMLStyle_get_posLeft(style, &f);
3951 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3952 ok(f == 4.0 ||
3953 f == 4.9f, /* IE8 */
3954 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3956 /* Ensure left is updated correctly. */
3957 V_VT(&v) = VT_EMPTY;
3958 hres = IHTMLStyle_get_left(style, &v);
3959 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3960 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3961 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3962 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3963 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3964 VariantClear(&v);
3966 /* Test left */
3967 V_VT(&v) = VT_BSTR;
3968 V_BSTR(&v) = a2bstr("3px");
3969 hres = IHTMLStyle_put_left(style, v);
3970 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3971 VariantClear(&v);
3973 hres = IHTMLStyle_get_posLeft(style, &f);
3974 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3975 ok(f == 3.0, "expected 3.0 got %f\n", f);
3977 V_VT(&v) = VT_EMPTY;
3978 hres = IHTMLStyle_get_left(style, &v);
3979 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3980 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3981 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3982 VariantClear(&v);
3984 V_VT(&v) = VT_NULL;
3985 hres = IHTMLStyle_put_left(style, v);
3986 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3988 V_VT(&v) = VT_EMPTY;
3989 hres = IHTMLStyle_get_left(style, &v);
3990 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3991 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3992 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3993 VariantClear(&v);
3995 V_VT(&v) = VT_EMPTY;
3996 hres = IHTMLStyle_get_top(style, &v);
3997 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3998 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3999 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4000 VariantClear(&v);
4002 /* Test posTop */
4003 hres = IHTMLStyle_get_posTop(style, NULL);
4004 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
4006 f = 1.0f;
4007 hres = IHTMLStyle_get_posTop(style, &f);
4008 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4009 ok(f == 0.0, "expected 0.0 got %f\n", f);
4011 hres = IHTMLStyle_put_posTop(style, 4.9f);
4012 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
4014 hres = IHTMLStyle_get_posTop(style, &f);
4015 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4016 ok(f == 4.0 ||
4017 f == 4.9f, /* IE8 */
4018 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4020 V_VT(&v) = VT_BSTR;
4021 V_BSTR(&v) = a2bstr("3px");
4022 hres = IHTMLStyle_put_top(style, v);
4023 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4024 VariantClear(&v);
4026 V_VT(&v) = VT_EMPTY;
4027 hres = IHTMLStyle_get_top(style, &v);
4028 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4029 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4030 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4031 VariantClear(&v);
4033 hres = IHTMLStyle_get_posTop(style, &f);
4034 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4035 ok(f == 3.0, "expected 3.0 got %f\n", f);
4037 V_VT(&v) = VT_NULL;
4038 hres = IHTMLStyle_put_top(style, v);
4039 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4041 V_VT(&v) = VT_EMPTY;
4042 hres = IHTMLStyle_get_top(style, &v);
4043 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4044 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4045 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4046 VariantClear(&v);
4048 /* Test posHeight */
4049 hres = IHTMLStyle_get_posHeight(style, NULL);
4050 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
4052 V_VT(&v) = VT_EMPTY;
4053 hres = IHTMLStyle_get_height(style, &v);
4054 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4055 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4056 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4057 VariantClear(&v);
4059 f = 1.0f;
4060 hres = IHTMLStyle_get_posHeight(style, &f);
4061 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4062 ok(f == 0.0, "expected 0.0 got %f\n", f);
4064 hres = IHTMLStyle_put_posHeight(style, 4.9f);
4065 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
4067 hres = IHTMLStyle_get_posHeight(style, &f);
4068 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4069 ok(f == 4.0 ||
4070 f == 4.9f, /* IE8 */
4071 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4073 V_VT(&v) = VT_BSTR;
4074 V_BSTR(&v) = a2bstr("64px");
4075 hres = IHTMLStyle_put_height(style, v);
4076 ok(hres == S_OK, "put_height failed: %08x\n", hres);
4077 VariantClear(&v);
4079 V_VT(&v) = VT_EMPTY;
4080 hres = IHTMLStyle_get_height(style, &v);
4081 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4082 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4083 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4084 VariantClear(&v);
4086 hres = IHTMLStyle_get_posHeight(style, &f);
4087 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4088 ok(f == 64.0, "expected 64.0 got %f\n", f);
4090 str = (void*)0xdeadbeef;
4091 hres = IHTMLStyle_get_cursor(style, &str);
4092 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4093 ok(!str, "get_cursor != NULL\n");
4094 SysFreeString(str);
4096 str = a2bstr("default");
4097 hres = IHTMLStyle_put_cursor(style, str);
4098 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
4099 SysFreeString(str);
4101 str = NULL;
4102 hres = IHTMLStyle_get_cursor(style, &str);
4103 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4104 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4105 SysFreeString(str);
4107 V_VT(&v) = VT_EMPTY;
4108 hres = IHTMLStyle_get_verticalAlign(style, &v);
4109 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
4110 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4111 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4112 VariantClear(&v);
4114 V_VT(&v) = VT_BSTR;
4115 V_BSTR(&v) = a2bstr("middle");
4116 hres = IHTMLStyle_put_verticalAlign(style, v);
4117 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
4118 VariantClear(&v);
4120 V_VT(&v) = VT_EMPTY;
4121 hres = IHTMLStyle_get_verticalAlign(style, &v);
4122 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4123 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4124 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4125 VariantClear(&v);
4127 str = (void*)0xdeadbeef;
4128 hres = IHTMLStyle_get_textAlign(style, &str);
4129 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4130 ok(!str, "textAlign != NULL\n");
4132 str = a2bstr("center");
4133 hres = IHTMLStyle_put_textAlign(style, str);
4134 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
4135 SysFreeString(str);
4137 str = NULL;
4138 hres = IHTMLStyle_get_textAlign(style, &str);
4139 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4140 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4141 SysFreeString(str);
4143 str = (void*)0xdeadbeef;
4144 hres = IHTMLStyle_get_filter(style, &str);
4145 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4146 ok(!str, "filter != NULL\n");
4148 str = a2bstr("alpha(opacity=100)");
4149 hres = IHTMLStyle_put_filter(style, str);
4150 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
4151 SysFreeString(str);
4153 V_VT(&v) = VT_EMPTY;
4154 hres = IHTMLStyle_get_zIndex(style, &v);
4155 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4156 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4157 ok(!V_I4(&v), "V_I4(v) != 0\n");
4158 VariantClear(&v);
4160 V_VT(&v) = VT_BSTR;
4161 V_BSTR(&v) = a2bstr("1");
4162 hres = IHTMLStyle_put_zIndex(style, v);
4163 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4164 VariantClear(&v);
4166 V_VT(&v) = VT_EMPTY;
4167 hres = IHTMLStyle_get_zIndex(style, &v);
4168 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4169 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4170 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4171 VariantClear(&v);
4173 /* fontStyle */
4174 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4175 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4177 str = a2bstr("test");
4178 hres = IHTMLStyle_put_fontStyle(style, str);
4179 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4180 SysFreeString(str);
4182 str = a2bstr("italic");
4183 hres = IHTMLStyle_put_fontStyle(style, str);
4184 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4185 SysFreeString(str);
4187 str = a2bstr("oblique");
4188 hres = IHTMLStyle_put_fontStyle(style, str);
4189 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4190 SysFreeString(str);
4192 str = a2bstr("normal");
4193 hres = IHTMLStyle_put_fontStyle(style, str);
4194 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4195 SysFreeString(str);
4197 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4198 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4199 SysFreeString(sDefault);
4201 /* overflow */
4202 hres = IHTMLStyle_get_overflow(style, NULL);
4203 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4205 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4206 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4208 str = a2bstr("test");
4209 hres = IHTMLStyle_put_overflow(style, str);
4210 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4211 SysFreeString(str);
4213 str = a2bstr("visible");
4214 hres = IHTMLStyle_put_overflow(style, str);
4215 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4216 SysFreeString(str);
4218 str = a2bstr("scroll");
4219 hres = IHTMLStyle_put_overflow(style, str);
4220 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4221 SysFreeString(str);
4223 str = a2bstr("hidden");
4224 hres = IHTMLStyle_put_overflow(style, str);
4225 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4226 SysFreeString(str);
4228 str = a2bstr("auto");
4229 hres = IHTMLStyle_put_overflow(style, str);
4230 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4231 SysFreeString(str);
4233 hres = IHTMLStyle_get_overflow(style, &str);
4234 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4235 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4236 SysFreeString(str);
4238 str = a2bstr("");
4239 hres = IHTMLStyle_put_overflow(style, str);
4240 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4241 SysFreeString(str);
4243 hres = IHTMLStyle_get_overflow(style, &str);
4244 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4245 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4246 SysFreeString(str);
4248 /* restore overflow default */
4249 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4250 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4251 SysFreeString(sOverflowDefault);
4253 /* Attribute Tests*/
4254 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4255 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4257 str = a2bstr("position");
4258 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4259 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4261 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4262 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4263 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4264 VariantClear(&v);
4266 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4267 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4269 V_VT(&v) = VT_BSTR;
4270 V_BSTR(&v) = a2bstr("absolute");
4271 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4272 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4273 VariantClear(&v);
4275 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4276 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4277 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4278 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4279 VariantClear(&v);
4281 V_VT(&v) = VT_BSTR;
4282 V_BSTR(&v) = NULL;
4283 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4284 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4285 VariantClear(&v);
4287 SysFreeString(str);
4289 str = a2bstr("borderLeftStyle");
4290 test_border_styles(style, str);
4291 SysFreeString(str);
4293 str = a2bstr("borderbottomstyle");
4294 test_border_styles(style, str);
4295 SysFreeString(str);
4297 str = a2bstr("borderrightstyle");
4298 test_border_styles(style, str);
4299 SysFreeString(str);
4301 str = a2bstr("bordertopstyle");
4302 test_border_styles(style, str);
4303 SysFreeString(str);
4305 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4306 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4308 str = a2bstr("none dotted dashed solid");
4309 hres = IHTMLStyle_put_borderStyle(style, str);
4310 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4311 SysFreeString(str);
4313 str = a2bstr("none dotted dashed solid");
4314 hres = IHTMLStyle_get_borderStyle(style, &str);
4315 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4316 ok(!strcmp_wa(str, "none dotted dashed solid"),
4317 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4318 SysFreeString(str);
4320 str = a2bstr("double groove ridge inset");
4321 hres = IHTMLStyle_put_borderStyle(style, str);
4322 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4323 SysFreeString(str);
4325 str = a2bstr("window-inset outset ridge inset");
4326 hres = IHTMLStyle_put_borderStyle(style, str);
4327 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4328 SysFreeString(str);
4330 str = a2bstr("window-inset");
4331 hres = IHTMLStyle_put_borderStyle(style, str);
4332 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4333 SysFreeString(str);
4335 str = a2bstr("none none none none none");
4336 hres = IHTMLStyle_put_borderStyle(style, str);
4337 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4338 SysFreeString(str);
4340 str = a2bstr("invalid none none none");
4341 hres = IHTMLStyle_put_borderStyle(style, str);
4342 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4343 SysFreeString(str);
4345 str = a2bstr("none invalid none none");
4346 hres = IHTMLStyle_put_borderStyle(style, str);
4347 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4348 SysFreeString(str);
4350 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4351 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4352 SysFreeString(sDefault);
4354 /* backgoundColor */
4355 hres = IHTMLStyle_get_backgroundColor(style, &v);
4356 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4357 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4358 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4359 VariantClear(&v);
4361 /* PaddingLeft */
4362 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4363 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4365 V_VT(&v) = VT_BSTR;
4366 V_BSTR(&v) = a2bstr("10");
4367 hres = IHTMLStyle_put_paddingLeft(style, v);
4368 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4369 VariantClear(&v);
4371 hres = IHTMLStyle_get_paddingLeft(style, &v);
4372 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4373 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4375 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4376 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4378 /* BackgroundRepeat */
4379 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4380 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4382 str = a2bstr("invalid");
4383 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4384 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4385 SysFreeString(str);
4387 str = a2bstr("repeat");
4388 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4389 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4390 SysFreeString(str);
4392 str = a2bstr("no-repeat");
4393 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4394 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4395 SysFreeString(str);
4397 str = a2bstr("repeat-x");
4398 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4399 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4400 SysFreeString(str);
4402 str = a2bstr("repeat-y");
4403 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4404 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4405 SysFreeString(str);
4407 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4408 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4409 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4410 SysFreeString(str);
4412 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4413 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4414 SysFreeString(sDefault);
4416 /* BorderColor */
4417 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4418 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4420 str = a2bstr("red green red blue");
4421 hres = IHTMLStyle_put_borderColor(style, str);
4422 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4423 SysFreeString(str);
4425 hres = IHTMLStyle_get_borderColor(style, &str);
4426 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4427 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4428 SysFreeString(str);
4430 hres = IHTMLStyle_put_borderColor(style, sDefault);
4431 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4432 SysFreeString(sDefault);
4434 /* BorderRight */
4435 hres = IHTMLStyle_get_borderRight(style, &sDefault);
4436 ok(hres == S_OK, "get_borderRight failed: %08x\n", hres);
4438 str = a2bstr("thick dotted red");
4439 hres = IHTMLStyle_put_borderRight(style, str);
4440 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
4441 SysFreeString(str);
4443 /* IHTMLStyle_get_borderRight appears to have a bug where
4444 it returns the first letter of the color. So we check
4445 each style individually.
4447 V_BSTR(&v) = NULL;
4448 hres = IHTMLStyle_get_borderRightColor(style, &v);
4449 todo_wine ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
4450 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4451 VariantClear(&v);
4453 V_BSTR(&v) = NULL;
4454 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4455 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
4456 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4457 VariantClear(&v);
4459 hres = IHTMLStyle_get_borderRightStyle(style, &str);
4460 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
4461 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4462 SysFreeString(str);
4464 hres = IHTMLStyle_put_borderRight(style, sDefault);
4465 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
4466 SysFreeString(sDefault);
4468 /* BorderTop */
4469 hres = IHTMLStyle_get_borderTop(style, &sDefault);
4470 ok(hres == S_OK, "get_borderTop failed: %08x\n", hres);
4472 str = a2bstr("thick dotted red");
4473 hres = IHTMLStyle_put_borderTop(style, str);
4474 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
4475 SysFreeString(str);
4477 /* IHTMLStyle_get_borderTop appears to have a bug where
4478 it returns the first letter of the color. So we check
4479 each style individually.
4481 V_BSTR(&v) = NULL;
4482 hres = IHTMLStyle_get_borderTopColor(style, &v);
4483 todo_wine ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
4484 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4485 VariantClear(&v);
4487 V_BSTR(&v) = NULL;
4488 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4489 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
4490 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4491 VariantClear(&v);
4493 hres = IHTMLStyle_get_borderTopStyle(style, &str);
4494 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
4495 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4496 SysFreeString(str);
4498 hres = IHTMLStyle_put_borderTop(style, sDefault);
4499 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
4500 SysFreeString(sDefault);
4502 /* BorderBottom */
4503 hres = IHTMLStyle_get_borderBottom(style, &sDefault);
4504 ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres);
4506 str = a2bstr("thick dotted red");
4507 hres = IHTMLStyle_put_borderBottom(style, str);
4508 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
4509 SysFreeString(str);
4511 /* IHTMLStyle_get_borderBottom appears to have a bug where
4512 it returns the first letter of the color. So we check
4513 each style individually.
4515 V_BSTR(&v) = NULL;
4516 hres = IHTMLStyle_get_borderBottomColor(style, &v);
4517 todo_wine ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
4518 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4519 VariantClear(&v);
4521 V_BSTR(&v) = NULL;
4522 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4523 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
4524 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4525 VariantClear(&v);
4527 hres = IHTMLStyle_get_borderBottomStyle(style, &str);
4528 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
4529 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4530 SysFreeString(str);
4532 hres = IHTMLStyle_put_borderBottom(style, sDefault);
4533 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
4534 SysFreeString(sDefault);
4536 /* BorderLeft */
4537 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4538 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4540 str = a2bstr("thick dotted red");
4541 hres = IHTMLStyle_put_borderLeft(style, str);
4542 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4543 SysFreeString(str);
4545 /* IHTMLStyle_get_borderLeft appears to have a bug where
4546 it returns the first letter of the color. So we check
4547 each style individually.
4549 V_BSTR(&v) = NULL;
4550 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4551 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4552 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4553 VariantClear(&v);
4555 V_BSTR(&v) = NULL;
4556 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4557 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4558 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4559 VariantClear(&v);
4561 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4562 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4563 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4564 SysFreeString(str);
4566 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4567 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4568 SysFreeString(sDefault);
4570 /* backgroundPositionX */
4571 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4572 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4574 V_VT(&v) = VT_BSTR;
4575 V_BSTR(&v) = a2bstr("10px");
4576 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4577 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4578 VariantClear(&v);
4580 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4581 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4582 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4583 VariantClear(&v);
4585 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4586 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4587 VariantClear(&vDefault);
4589 /* backgroundPositionY */
4590 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4591 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4593 V_VT(&v) = VT_BSTR;
4594 V_BSTR(&v) = a2bstr("10px");
4595 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4596 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4597 VariantClear(&v);
4599 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4600 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4601 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4602 VariantClear(&v);
4604 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4605 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4606 VariantClear(&vDefault);
4608 /* borderTopWidth */
4609 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4610 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4612 V_VT(&v) = VT_BSTR;
4613 V_BSTR(&v) = a2bstr("10px");
4614 hres = IHTMLStyle_put_borderTopWidth(style, v);
4615 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4616 VariantClear(&v);
4618 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4619 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4620 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4621 VariantClear(&v);
4623 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4624 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4625 VariantClear(&vDefault);
4627 /* borderRightWidth */
4628 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4629 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4631 V_VT(&v) = VT_BSTR;
4632 V_BSTR(&v) = a2bstr("10");
4633 hres = IHTMLStyle_put_borderRightWidth(style, v);
4634 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4635 VariantClear(&v);
4637 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4638 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4639 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4640 VariantClear(&v);
4642 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4643 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4644 VariantClear(&vDefault);
4646 /* borderBottomWidth */
4647 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4648 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4650 V_VT(&v) = VT_BSTR;
4651 V_BSTR(&v) = a2bstr("10");
4652 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4653 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4654 VariantClear(&v);
4656 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4657 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4658 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4659 VariantClear(&v);
4661 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4662 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4663 VariantClear(&vDefault);
4665 /* borderLeftWidth */
4666 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4667 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4669 V_VT(&v) = VT_BSTR;
4670 V_BSTR(&v) = a2bstr("10");
4671 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4672 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4673 VariantClear(&v);
4675 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4676 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4677 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4678 VariantClear(&v);
4680 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4681 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4682 VariantClear(&vDefault);
4684 /* wordSpacing */
4685 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4686 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4688 V_VT(&v) = VT_BSTR;
4689 V_BSTR(&v) = a2bstr("10");
4690 hres = IHTMLStyle_put_wordSpacing(style, v);
4691 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4692 VariantClear(&v);
4694 hres = IHTMLStyle_get_wordSpacing(style, &v);
4695 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4696 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4697 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4698 VariantClear(&v);
4700 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4701 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4702 VariantClear(&vDefault);
4704 /* letterSpacing */
4705 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4706 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4708 V_VT(&v) = VT_BSTR;
4709 V_BSTR(&v) = a2bstr("11");
4710 hres = IHTMLStyle_put_letterSpacing(style, v);
4711 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4712 VariantClear(&v);
4714 hres = IHTMLStyle_get_letterSpacing(style, &v);
4715 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4716 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4717 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4718 VariantClear(&v);
4720 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4721 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4722 VariantClear(&vDefault);
4724 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4725 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4726 if(SUCCEEDED(hres)) {
4727 test_style2(style2);
4728 IHTMLStyle2_Release(style2);
4731 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4732 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4733 if(SUCCEEDED(hres)) {
4734 test_style3(style3);
4735 IHTMLStyle3_Release(style3);
4738 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4739 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4740 if(SUCCEEDED(hres)) {
4741 test_style4(style4);
4742 IHTMLStyle4_Release(style4);
4746 static void test_set_csstext(IHTMLStyle *style)
4748 VARIANT v;
4749 HRESULT hres;
4751 test_style_set_csstext(style, "background-color: black;");
4753 hres = IHTMLStyle_get_backgroundColor(style, &v);
4754 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4755 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4756 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4757 VariantClear(&v);
4760 static void test_default_selection(IHTMLDocument2 *doc)
4762 IHTMLSelectionObject *selection;
4763 IHTMLTxtRange *range;
4764 IDispatch *disp;
4765 BSTR str;
4766 HRESULT hres;
4768 hres = IHTMLDocument2_get_selection(doc, &selection);
4769 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4771 hres = IHTMLSelectionObject_get_type(selection, &str);
4772 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4773 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4774 SysFreeString(str);
4776 hres = IHTMLSelectionObject_createRange(selection, &disp);
4777 IHTMLSelectionObject_Release(selection);
4778 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4780 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4781 IDispatch_Release(disp);
4782 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4784 test_range_text(range, NULL);
4785 IHTMLTxtRange_Release(range);
4788 static void test_doc_elem(IHTMLDocument2 *doc)
4790 IHTMLDocument2 *doc_node, *owner_doc;
4791 IHTMLElement *elem;
4792 IHTMLDocument3 *doc3;
4793 HRESULT hres;
4795 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4796 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4798 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4799 IHTMLDocument3_Release(doc3);
4800 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4802 test_node_name((IUnknown*)elem, "HTML");
4803 test_elem_tag((IUnknown*)elem, "HTML");
4805 doc_node = get_doc_node(doc);
4806 owner_doc = get_owner_doc((IUnknown*)elem);
4807 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4808 IHTMLDocument2_Release(owner_doc);
4810 owner_doc = get_owner_doc((IUnknown*)doc_node);
4811 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4812 IHTMLDocument2_Release(doc_node);
4814 test_elem_client_rect((IUnknown*)elem);
4816 IHTMLElement_Release(elem);
4819 static void test_default_body(IHTMLBodyElement *body)
4821 LONG l;
4822 BSTR bstr;
4823 HRESULT hres;
4824 VARIANT v;
4826 bstr = (void*)0xdeadbeef;
4827 hres = IHTMLBodyElement_get_background(body, &bstr);
4828 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4829 ok(bstr == NULL, "bstr != NULL\n");
4831 l = elem_get_scroll_height((IUnknown*)body);
4832 ok(l != -1, "scrollHeight == -1\n");
4833 l = elem_get_scroll_width((IUnknown*)body);
4834 ok(l != -1, "scrollWidth == -1\n");
4835 l = elem_get_scroll_top((IUnknown*)body);
4836 ok(!l, "scrollTop = %d\n", l);
4837 elem_get_scroll_left((IUnknown*)body);
4839 /* get_text tests */
4840 hres = IHTMLBodyElement_get_text(body, &v);
4841 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4842 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4843 ok(bstr == NULL, "bstr != NULL\n");
4845 /* get_text - Invalid Text */
4846 V_VT(&v) = VT_BSTR;
4847 V_BSTR(&v) = a2bstr("Invalid");
4848 hres = IHTMLBodyElement_put_text(body, v);
4849 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4850 VariantClear(&v);
4852 V_VT(&v) = VT_NULL;
4853 hres = IHTMLBodyElement_get_text(body, &v);
4854 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4855 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4856 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
4857 VariantClear(&v);
4859 /* get_text - Valid Text */
4860 V_VT(&v) = VT_BSTR;
4861 V_BSTR(&v) = a2bstr("#FF0000");
4862 hres = IHTMLBodyElement_put_text(body, v);
4863 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4864 VariantClear(&v);
4866 V_VT(&v) = VT_NULL;
4867 hres = IHTMLBodyElement_get_text(body, &v);
4868 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4869 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4870 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
4871 VariantClear(&v);
4874 static void test_body_funs(IHTMLBodyElement *body)
4876 VARIANT vbg, vDefaultbg;
4877 HRESULT hres;
4879 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4880 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4881 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4882 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
4884 V_VT(&vbg) = VT_BSTR;
4885 V_BSTR(&vbg) = a2bstr("red");
4886 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4887 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4888 VariantClear(&vbg);
4890 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4891 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4892 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4893 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4894 VariantClear(&vbg);
4896 /* Restore Originial */
4897 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4898 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4899 VariantClear(&vDefaultbg);
4902 static void test_window(IHTMLDocument2 *doc)
4904 IHTMLWindow2 *window, *window2, *self;
4905 IHTMLDocument2 *doc2 = NULL;
4906 IDispatch *disp;
4907 IUnknown *unk;
4908 BSTR str;
4909 HRESULT hres;
4911 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4912 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4913 test_ifaces((IUnknown*)window, window_iids);
4914 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4916 hres = IHTMLWindow2_get_document(window, &doc2);
4917 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4918 ok(doc2 != NULL, "doc2 == NULL\n");
4920 test_ifaces((IUnknown*)doc2, doc_node_iids);
4921 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4923 test_ifaces((IUnknown*)doc, doc_obj_iids);
4924 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4926 unk = (void*)0xdeadbeef;
4927 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4928 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4929 ok(!unk, "unk = %p\n", unk);
4931 IHTMLDocument_Release(doc2);
4933 hres = IHTMLWindow2_get_window(window, &window2);
4934 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4935 ok(window2 != NULL, "window2 == NULL\n");
4937 hres = IHTMLWindow2_get_self(window, &self);
4938 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4939 ok(window2 != NULL, "self == NULL\n");
4941 ok(self == window2, "self != window2\n");
4943 IHTMLWindow2_Release(window2);
4944 IHTMLWindow2_Release(self);
4946 disp = NULL;
4947 hres = IHTMLDocument2_get_Script(doc, &disp);
4948 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4949 ok(disp == (void*)window, "disp != window\n");
4950 IDispatch_Release(disp);
4952 hres = IHTMLWindow2_toString(window, NULL);
4953 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4955 str = NULL;
4956 hres = IHTMLWindow2_toString(window, &str);
4957 ok(hres == S_OK, "toString failed: %08x\n", hres);
4958 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4959 SysFreeString(str);
4961 test_window_name(window, NULL);
4962 set_window_name(window, "test");
4963 test_window_length(window, 0);
4964 test_screen(window);
4966 IHTMLWindow2_Release(window);
4969 static void test_defaults(IHTMLDocument2 *doc)
4971 IHTMLStyleSheetsCollection *stylesheetcol;
4972 IHTMLCurrentStyle *cstyle;
4973 IHTMLBodyElement *body;
4974 IHTMLElement2 *elem2;
4975 IHTMLElement *elem;
4976 IHTMLStyle *style;
4977 LONG l;
4978 HRESULT hres;
4979 IHTMLElementCollection *collection;
4981 hres = IHTMLDocument2_get_body(doc, &elem);
4982 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4984 hres = IHTMLDocument2_get_images(doc, NULL);
4985 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4987 hres = IHTMLDocument2_get_images(doc, &collection);
4988 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4989 if(hres == S_OK)
4991 test_elem_collection((IUnknown*)collection, NULL, 0);
4992 IHTMLElementCollection_Release(collection);
4995 hres = IHTMLDocument2_get_applets(doc, NULL);
4996 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4998 hres = IHTMLDocument2_get_applets(doc, &collection);
4999 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
5000 if(hres == S_OK)
5002 test_elem_collection((IUnknown*)collection, NULL, 0);
5003 IHTMLElementCollection_Release(collection);
5006 hres = IHTMLDocument2_get_links(doc, NULL);
5007 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5009 hres = IHTMLDocument2_get_links(doc, &collection);
5010 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5011 if(hres == S_OK)
5013 test_elem_collection((IUnknown*)collection, NULL, 0);
5014 IHTMLElementCollection_Release(collection);
5017 hres = IHTMLDocument2_get_forms(doc, NULL);
5018 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5020 hres = IHTMLDocument2_get_forms(doc, &collection);
5021 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
5022 if(hres == S_OK)
5024 test_elem_collection((IUnknown*)collection, NULL, 0);
5025 IHTMLElementCollection_Release(collection);
5028 hres = IHTMLDocument2_get_anchors(doc, NULL);
5029 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5031 hres = IHTMLDocument2_get_anchors(doc, &collection);
5032 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5033 if(hres == S_OK)
5035 test_elem_collection((IUnknown*)collection, NULL, 0);
5036 IHTMLElementCollection_Release(collection);
5039 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
5040 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
5041 test_default_body(body);
5042 test_body_funs(body);
5043 IHTMLBodyElement_Release(body);
5045 hres = IHTMLElement_get_style(elem, &style);
5046 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5048 test_default_style(style);
5049 test_window(doc);
5050 test_compatmode(doc);
5051 test_location(doc);
5052 test_navigator(doc);
5054 elem2 = get_elem2_iface((IUnknown*)elem);
5055 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
5056 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
5057 if(SUCCEEDED(hres)) {
5058 test_current_style(cstyle);
5059 IHTMLCurrentStyle_Release(cstyle);
5061 IHTMLElement2_Release(elem2);
5063 IHTMLElement_Release(elem);
5065 test_set_csstext(style);
5066 IHTMLStyle_Release(style);
5068 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
5069 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5071 l = 0xdeadbeef;
5072 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
5073 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5074 ok(l == 0, "length = %d\n", l);
5076 IHTMLStyleSheetsCollection_Release(stylesheetcol);
5078 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
5079 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
5081 test_default_selection(doc);
5082 test_doc_title(doc, "");
5085 static void test_tr_elem(IHTMLElement *elem)
5087 IHTMLElementCollection *col;
5088 IHTMLTableRow *row;
5089 HRESULT hres;
5091 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
5093 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
5094 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
5095 if(FAILED(hres))
5096 return;
5098 col = NULL;
5099 hres = IHTMLTableRow_get_cells(row, &col);
5100 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
5101 ok(col != NULL, "get_cells returned NULL\n");
5103 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
5104 IHTMLElementCollection_Release(col);
5106 IHTMLTable_Release(row);
5109 static void test_table_elem(IHTMLElement *elem)
5111 IHTMLElementCollection *col;
5112 IHTMLTable *table;
5113 IHTMLDOMNode *node;
5114 HRESULT hres;
5116 static const elem_type_t row_types[] = {ET_TR,ET_TR};
5117 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
5119 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
5120 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
5121 if(FAILED(hres))
5122 return;
5124 col = NULL;
5125 hres = IHTMLTable_get_rows(table, &col);
5126 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
5127 ok(col != NULL, "get_ros returned NULL\n");
5129 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
5130 IHTMLElementCollection_Release(col);
5132 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
5134 node = clone_node((IUnknown*)table, VARIANT_TRUE);
5135 test_elem_tag((IUnknown*)node, "TABLE");
5136 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
5137 IHTMLDOMNode_Release(node);
5139 node = clone_node((IUnknown*)table, VARIANT_FALSE);
5140 test_elem_tag((IUnknown*)node, "TABLE");
5141 test_elem_all((IUnknown*)node, NULL, 0);
5142 IHTMLDOMNode_Release(node);
5144 IHTMLTable_Release(table);
5147 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
5149 SAFEARRAYBOUND dim;
5150 SAFEARRAY *sa;
5151 VARIANT *var;
5152 BSTR str;
5153 HRESULT hres;
5155 dim.lLbound = 0;
5156 dim.cElements = 1;
5157 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
5158 SafeArrayAccessData(sa, (void**)&var);
5159 V_VT(var) = VT_BSTR;
5160 V_BSTR(var) = str = a2bstr(text);
5161 SafeArrayUnaccessData(sa);
5163 if(ln)
5164 hres = IHTMLDocument2_writeln(doc, sa);
5165 else
5166 hres = IHTMLDocument2_write(doc, sa);
5167 ok(hres == S_OK, "write failed: %08x\n", hres);
5169 SysFreeString(str);
5170 SafeArrayDestroy(sa);
5173 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
5175 IHTMLDocument2 *window_doc, *elem_doc;
5176 IHTMLFrameElement3 *frame_elem3;
5177 IHTMLWindow2 *content_window;
5178 HRESULT hres;
5180 content_window = get_frame_content_window(frame_elem);
5181 window_doc = get_window_doc(content_window);
5182 IHTMLWindow2_Release(content_window);
5184 elem_doc = get_elem_doc(frame_elem);
5185 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
5187 if(!iframe) {
5188 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
5189 if(SUCCEEDED(hres)) {
5190 IDispatch *disp = NULL;
5192 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
5193 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
5194 ok(disp != NULL, "contentDocument == NULL\n");
5195 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
5197 IDispatch_Release(disp);
5198 IHTMLFrameElement3_Release(frame_elem3);
5199 }else {
5200 win_skip("IHTMLFrameElement3 not supported\n");
5204 IHTMLDocument2_Release(elem_doc);
5205 IHTMLDocument2_Release(window_doc);
5208 static void test_iframe_elem(IHTMLElement *elem)
5210 IHTMLDocument2 *content_doc, *owner_doc;
5211 IHTMLElementCollection *col;
5212 IHTMLWindow2 *content_window;
5213 IDispatch *disp;
5214 VARIANT errv;
5215 BSTR str;
5216 HRESULT hres;
5218 static const elem_type_t all_types[] = {
5219 ET_HTML,
5220 ET_HEAD,
5221 ET_TITLE,
5222 ET_BODY,
5223 ET_BR
5226 test_frame_doc((IUnknown*)elem, TRUE);
5228 content_window = get_frame_content_window((IUnknown*)elem);
5229 test_window_length(content_window, 0);
5231 content_doc = get_window_doc(content_window);
5232 IHTMLWindow2_Release(content_window);
5234 str = a2bstr("text/html");
5235 V_VT(&errv) = VT_ERROR;
5236 disp = NULL;
5237 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
5238 SysFreeString(str);
5239 ok(hres == S_OK, "open failed: %08x\n", hres);
5240 ok(disp != NULL, "disp == NULL\n");
5241 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
5242 IDispatch_Release(disp);
5244 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
5245 doc_write(content_doc, TRUE, "</html>");
5247 hres = IHTMLDocument2_get_all(content_doc, &col);
5248 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5249 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5250 IHTMLElementCollection_Release(col);
5252 hres = IHTMLDocument2_close(content_doc);
5253 ok(hres == S_OK, "close failed: %08x\n", hres);
5255 owner_doc = get_owner_doc((IUnknown*)content_doc);
5256 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5258 IHTMLDocument2_Release(content_doc);
5261 static void test_stylesheet(IDispatch *disp)
5263 IHTMLStyleSheetRulesCollection *col = NULL;
5264 IHTMLStyleSheet *stylesheet;
5265 HRESULT hres;
5267 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
5268 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
5270 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
5271 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
5272 ok(col != NULL, "col == NULL\n");
5274 IHTMLStyleSheetRulesCollection_Release(col);
5275 IHTMLStyleSheet_Release(stylesheet);
5278 static void test_stylesheets(IHTMLDocument2 *doc)
5280 IHTMLStyleSheetsCollection *col = NULL;
5281 VARIANT idx, res;
5282 LONG len = 0;
5283 HRESULT hres;
5285 hres = IHTMLDocument2_get_styleSheets(doc, &col);
5286 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5287 ok(col != NULL, "col == NULL\n");
5289 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
5290 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5291 ok(len == 1, "len=%d\n", len);
5293 VariantInit(&res);
5294 V_VT(&idx) = VT_I4;
5295 V_I4(&idx) = 0;
5297 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5298 ok(hres == S_OK, "item failed: %08x\n", hres);
5299 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
5300 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5301 test_stylesheet(V_DISPATCH(&res));
5302 VariantClear(&res);
5304 V_VT(&res) = VT_I4;
5305 V_VT(&idx) = VT_I4;
5306 V_I4(&idx) = 1;
5308 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5309 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5310 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
5311 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5312 VariantClear(&res);
5314 IHTMLStyleSheetsCollection_Release(col);
5317 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
5319 IDispatchEx *dispex;
5320 IHTMLDOMNode *node;
5321 DISPPARAMS dp = {NULL, NULL, 0, 0};
5322 VARIANT var;
5323 EXCEPINFO ei;
5324 LONG type;
5325 DISPID id;
5326 BSTR bstr;
5327 HRESULT hres;
5329 static const WCHAR w0[] = {'0',0};
5330 static const WCHAR w100[] = {'1','0','0',0};
5332 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
5333 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
5335 bstr = SysAllocString(w0);
5336 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5337 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5338 SysFreeString(bstr);
5340 VariantInit(&var);
5341 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
5342 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
5343 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
5344 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
5345 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
5346 type = get_node_type((IUnknown*)node);
5347 ok(type == 3, "type=%d\n", type);
5348 IHTMLDOMNode_Release(node);
5349 VariantClear(&var);
5351 bstr = SysAllocString(w100);
5352 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5353 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
5354 SysFreeString(bstr);
5356 IDispatchEx_Release(dispex);
5361 static void test_elems(IHTMLDocument2 *doc)
5363 IHTMLElementCollection *col;
5364 IHTMLDOMChildrenCollection *child_col;
5365 IHTMLElement *elem, *elem2, *elem3;
5366 IHTMLDOMNode *node, *node2;
5367 IHTMLWindow2 *window;
5368 IDispatch *disp;
5369 LONG type;
5370 HRESULT hres;
5371 IHTMLElementCollection *collection;
5372 IHTMLDocument3 *doc3;
5373 BSTR str;
5375 static const elem_type_t all_types[] = {
5376 ET_HTML,
5377 ET_HEAD,
5378 ET_TITLE,
5379 ET_STYLE,
5380 ET_BODY,
5381 ET_COMMENT,
5382 ET_A,
5383 ET_INPUT,
5384 ET_SELECT,
5385 ET_OPTION,
5386 ET_OPTION,
5387 ET_TEXTAREA,
5388 ET_TABLE,
5389 ET_TBODY,
5390 ET_TR,
5391 ET_TR,
5392 ET_TD,
5393 ET_TD,
5394 ET_SCRIPT,
5395 ET_TEST,
5396 ET_IMG,
5397 ET_IFRAME,
5398 ET_FORM
5401 static const elem_type_t item_types[] = {
5402 ET_A,
5403 ET_OPTION,
5404 ET_TEXTAREA
5407 hres = IHTMLDocument2_get_all(doc, &col);
5408 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5409 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5410 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5411 IHTMLElementCollection_Release(col);
5413 hres = IHTMLDocument2_get_images(doc, &collection);
5414 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5415 if(hres == S_OK)
5417 static const elem_type_t images_types[] = {ET_IMG};
5418 test_elem_collection((IUnknown*)collection, images_types, 1);
5420 IHTMLElementCollection_Release(collection);
5423 hres = IHTMLDocument2_get_links(doc, &collection);
5424 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5425 if(hres == S_OK)
5427 static const elem_type_t images_types[] = {ET_A};
5428 test_elem_collection((IUnknown*)collection, images_types, 1);
5430 IHTMLElementCollection_Release(collection);
5433 hres = IHTMLDocument2_get_anchors(doc, &collection);
5434 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5435 if(hres == S_OK)
5437 static const elem_type_t anchor_types[] = {ET_A};
5438 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5440 IHTMLElementCollection_Release(collection);
5443 elem = get_doc_elem(doc);
5444 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5445 IHTMLElement_Release(elem);
5447 get_elem_by_id(doc, "xxx", FALSE);
5448 elem = get_doc_elem_by_id(doc, "xxx");
5449 ok(!elem, "elem != NULL\n");
5451 elem = get_doc_elem_by_id(doc, "s");
5452 ok(elem != NULL, "elem == NULL\n");
5453 if(elem) {
5454 test_elem_type((IUnknown*)elem, ET_SELECT);
5455 test_elem_attr(elem, "xxx", NULL);
5456 test_elem_attr(elem, "id", "s");
5457 test_elem_class((IUnknown*)elem, NULL);
5458 test_elem_set_class((IUnknown*)elem, "cl");
5459 test_elem_set_class((IUnknown*)elem, NULL);
5460 test_elem_tabindex((IUnknown*)elem, 0);
5461 test_elem_set_tabindex((IUnknown*)elem, 1);
5462 test_elem_filters((IUnknown*)elem);
5464 node = test_node_get_parent((IUnknown*)elem);
5465 ok(node != NULL, "node == NULL\n");
5466 test_node_name((IUnknown*)node, "BODY");
5467 node2 = test_node_get_parent((IUnknown*)node);
5468 IHTMLDOMNode_Release(node);
5469 ok(node2 != NULL, "node == NULL\n");
5470 test_node_name((IUnknown*)node2, "HTML");
5471 node = test_node_get_parent((IUnknown*)node2);
5472 IHTMLDOMNode_Release(node2);
5473 ok(node != NULL, "node == NULL\n");
5474 if (node)
5476 test_node_name((IUnknown*)node, "#document");
5477 type = get_node_type((IUnknown*)node);
5478 ok(type == 9, "type=%d, expected 9\n", type);
5479 node2 = test_node_get_parent((IUnknown*)node);
5480 IHTMLDOMNode_Release(node);
5481 ok(node2 == NULL, "node != NULL\n");
5484 elem2 = test_elem_get_parent((IUnknown*)elem);
5485 ok(elem2 != NULL, "elem2 == NULL\n");
5486 test_node_name((IUnknown*)elem2, "BODY");
5487 elem3 = test_elem_get_parent((IUnknown*)elem2);
5488 IHTMLElement_Release(elem2);
5489 ok(elem3 != NULL, "elem3 == NULL\n");
5490 test_node_name((IUnknown*)elem3, "HTML");
5491 elem2 = test_elem_get_parent((IUnknown*)elem3);
5492 IHTMLElement_Release(elem3);
5493 ok(elem2 == NULL, "elem2 != NULL\n");
5495 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5496 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5497 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5499 test_elem_innertext(elem, "opt1opt2");
5501 IHTMLElement_Release(elem);
5504 elem = get_elem_by_id(doc, "s", TRUE);
5505 if(elem) {
5506 IHTMLSelectElement *select;
5507 IHTMLDocument2 *doc_node, *elem_doc;
5509 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
5510 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
5512 test_select_elem(select);
5514 test_elem_title((IUnknown*)select, NULL);
5515 test_elem_set_title((IUnknown*)select, "Title");
5516 test_elem_title((IUnknown*)select, "Title");
5517 test_elem_offset((IUnknown*)select);
5519 node = get_first_child((IUnknown*)select);
5520 ok(node != NULL, "node == NULL\n");
5521 if(node) {
5522 test_elem_type((IUnknown*)node, ET_OPTION);
5523 IHTMLDOMNode_Release(node);
5526 type = get_node_type((IUnknown*)select);
5527 ok(type == 1, "type=%d\n", type);
5529 IHTMLSelectElement_Release(select);
5531 elem_doc = get_elem_doc((IUnknown*)elem);
5533 doc_node = get_doc_node(doc);
5534 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
5535 IHTMLDocument2_Release(doc_node);
5536 IHTMLDocument2_Release(elem_doc);
5538 IHTMLElement_Release(elem);
5541 elem = get_elem_by_id(doc, "sc", TRUE);
5542 if(elem) {
5543 IHTMLScriptElement *script;
5544 BSTR type;
5546 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5547 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5549 if(hres == S_OK)
5551 VARIANT_BOOL vb;
5553 hres = IHTMLScriptElement_get_type(script, &type);
5554 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5555 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5556 SysFreeString(type);
5558 /* test defer */
5559 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5560 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5562 hres = IHTMLScriptElement_get_defer(script, &vb);
5563 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5564 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5566 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5567 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5570 IHTMLScriptElement_Release(script);
5573 elem = get_elem_by_id(doc, "in", TRUE);
5574 if(elem) {
5575 IHTMLInputElement *input;
5577 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5578 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5580 test_elem_id((IUnknown*)elem, "in");
5581 test_elem_put_id((IUnknown*)elem, "newin");
5582 test_input_get_disabled(input, VARIANT_FALSE);
5583 test_input_set_disabled(input, VARIANT_TRUE);
5584 test_input_set_disabled(input, VARIANT_FALSE);
5585 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5586 test_input_get_disabled(input, VARIANT_TRUE);
5587 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5588 test_input_get_disabled(input, VARIANT_FALSE);
5589 test_elem_client_size((IUnknown*)elem);
5591 test_node_get_value_str((IUnknown*)elem, NULL);
5592 test_node_put_value_str((IUnknown*)elem, "test");
5593 test_node_get_value_str((IUnknown*)elem, NULL);
5594 test_input_value((IUnknown*)elem, NULL);
5595 test_input_put_value((IUnknown*)elem, "test");
5596 test_input_value((IUnknown*)elem, NULL);
5597 test_elem_class((IUnknown*)elem, "testclass");
5598 test_elem_tabindex((IUnknown*)elem, 2);
5599 test_elem_set_tabindex((IUnknown*)elem, 3);
5600 test_elem_title((IUnknown*)elem, "test title");
5602 test_input_get_defaultchecked(input, VARIANT_FALSE);
5603 test_input_set_defaultchecked(input, VARIANT_TRUE);
5604 test_input_set_defaultchecked(input, VARIANT_FALSE);
5606 test_input_get_checked(input, VARIANT_FALSE);
5607 test_input_set_checked(input, VARIANT_TRUE);
5608 test_input_set_checked(input, VARIANT_FALSE);
5610 test_input_src(input, NULL);
5611 test_input_set_src(input, "about:blank");
5613 IHTMLInputElement_Release(input);
5614 IHTMLElement_Release(elem);
5617 elem = get_elem_by_id(doc, "imgid", TRUE);
5618 if(elem) {
5619 test_img_src((IUnknown*)elem, "");
5620 test_img_set_src((IUnknown*)elem, "about:blank");
5621 test_img_alt((IUnknown*)elem, NULL);
5622 test_img_set_alt((IUnknown*)elem, "alt test");
5623 test_img_name((IUnknown*)elem, "WineImg");
5624 IHTMLElement_Release(elem);
5627 elem = get_doc_elem_by_id(doc, "tbl");
5628 ok(elem != NULL, "elem == NULL\n");
5629 if(elem) {
5630 test_table_elem(elem);
5631 IHTMLElement_Release(elem);
5634 elem = get_doc_elem_by_id(doc, "row2");
5635 ok(elem != NULL, "elem == NULL\n");
5636 if(elem) {
5637 test_tr_elem(elem);
5638 IHTMLElement_Release(elem);
5641 elem = get_doc_elem_by_id(doc, "ifr");
5642 ok(elem != NULL, "elem == NULL\n");
5643 if(elem) {
5644 test_iframe_elem(elem);
5645 IHTMLElement_Release(elem);
5648 elem = get_elem_by_id(doc, "a", TRUE);
5649 if(elem) {
5650 test_anchor_href((IUnknown*)elem, "http://test/");
5651 IHTMLElement_Release(elem);
5654 hres = IHTMLDocument2_get_body(doc, &elem);
5655 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5657 node = get_first_child((IUnknown*)elem);
5658 ok(node != NULL, "node == NULL\n");
5659 if(node) {
5660 test_ifaces((IUnknown*)node, text_iids);
5661 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5663 node2 = get_first_child((IUnknown*)node);
5664 ok(!node2, "node2 != NULL\n");
5666 type = get_node_type((IUnknown*)node);
5667 ok(type == 3, "type=%d\n", type);
5669 test_node_get_value_str((IUnknown*)node, "text test");
5670 test_node_put_value_str((IUnknown*)elem, "test text");
5671 test_node_get_value_str((IUnknown*)node, "text test");
5673 IHTMLDOMNode_Release(node);
5676 child_col = get_child_nodes((IUnknown*)elem);
5677 ok(child_col != NULL, "child_coll == NULL\n");
5678 if(child_col) {
5679 LONG length = 0;
5681 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5683 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5684 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5685 ok(length, "length=0\n");
5687 node2 = NULL;
5688 node = get_child_item(child_col, 0);
5689 ok(node != NULL, "node == NULL\n");
5690 if(node) {
5691 type = get_node_type((IUnknown*)node);
5692 ok(type == 3, "type=%d\n", type);
5693 node2 = node_get_next((IUnknown*)node);
5694 IHTMLDOMNode_Release(node);
5697 node = get_child_item(child_col, 1);
5698 ok(node != NULL, "node == NULL\n");
5699 if(node) {
5700 type = get_node_type((IUnknown*)node);
5701 ok(type == 8, "type=%d\n", type);
5703 test_elem_id((IUnknown*)node, NULL);
5704 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
5705 IHTMLDOMNode_Release(node2);
5706 IHTMLDOMNode_Release(node);
5709 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5710 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5712 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5713 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5715 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5716 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5718 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5719 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5721 test_child_col_disp(child_col);
5723 IHTMLDOMChildrenCollection_Release(child_col);
5726 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5727 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5728 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5730 IHTMLElement_Release(elem);
5732 test_stylesheets(doc);
5733 test_create_option_elem(doc);
5734 test_create_img_elem(doc);
5736 elem = get_doc_elem_by_id(doc, "tbl");
5737 ok(elem != NULL, "elem = NULL\n");
5738 test_elem_set_innertext(elem, "inner text");
5739 IHTMLElement_Release(elem);
5741 test_doc_title(doc, "test");
5742 test_doc_set_title(doc, "test title");
5743 test_doc_title(doc, "test title");
5745 disp = NULL;
5746 hres = IHTMLDocument2_get_Script(doc, &disp);
5747 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5748 if(hres == S_OK)
5750 IDispatchEx *dispex;
5751 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5752 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5753 if(hres == S_OK)
5755 DISPID pid = -1;
5756 BSTR str = a2bstr("Testing");
5757 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5758 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5759 ok(pid != -1, "pid == -1\n");
5760 SysFreeString(str);
5761 IDispatchEx_Release(dispex);
5764 IDispatch_Release(disp);
5766 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5767 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5769 str = a2bstr("img");
5770 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5771 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5772 SysFreeString(str);
5773 if(hres == S_OK)
5775 static const elem_type_t img_types[] = { ET_IMG };
5777 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5778 IHTMLElementCollection_Release(col);
5781 elem = get_doc_elem_by_id(doc, "y");
5782 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5783 test_elem_innerhtml((IUnknown*)elem, "inner html");
5784 test_elem_set_innerhtml((IUnknown*)elem, "");
5785 test_elem_innerhtml((IUnknown*)elem, NULL);
5786 node = node_get_next((IUnknown*)elem);
5787 ok(!node, "node = %p\n", node);
5789 elem2 = get_doc_elem_by_id(doc, "x");
5790 test_elem_tag((IUnknown*)elem2, "A");
5791 node = node_get_next((IUnknown*)elem2);
5792 IHTMLDOMNode_Release(node);
5793 IHTMLElement_Release(elem2);
5794 IHTMLElement_Release(elem);
5796 IHTMLDocument3_Release(doc3);
5798 window = get_doc_window(doc);
5799 test_window_name(window, NULL);
5800 set_window_name(window, "test name");
5801 test_window_length(window, 1);
5802 IHTMLWindow2_Release(window);
5805 static void test_elems2(IHTMLDocument2 *doc)
5807 IHTMLElement *elem, *elem2;
5809 static const elem_type_t outer_types[] = {
5810 ET_BR,
5811 ET_A
5814 elem = get_doc_elem_by_id(doc, "divid");
5816 test_elem_set_innerhtml((IUnknown*)elem, "<div id=\"innerid\"></div>");
5817 elem2 = get_doc_elem_by_id(doc, "innerid");
5818 ok(elem2 != NULL, "elem2 == NULL\n");
5819 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5820 test_elem_all((IUnknown*)elem, outer_types, sizeof(outer_types)/sizeof(*outer_types));
5821 IHTMLElement_Release(elem2);
5823 elem2 = get_doc_elem_by_id(doc, "aid");
5824 ok(elem2 != NULL, "elem2 == NULL\n");
5825 test_elem_set_outerhtml((IUnknown*)elem2, "");
5826 test_elem_all((IUnknown*)elem, outer_types, 1);
5827 IHTMLElement_Release(elem2);
5829 IHTMLElement_Release(elem);
5832 static void test_create_elems(IHTMLDocument2 *doc)
5834 IHTMLElement *elem, *body, *elem2;
5835 IHTMLDOMNode *node, *node2, *node3, *comment;
5836 IHTMLDocument5 *doc5;
5837 IDispatch *disp;
5838 VARIANT var;
5839 LONG type;
5840 HRESULT hres;
5841 BSTR str;
5843 static const elem_type_t types1[] = { ET_TESTG };
5845 elem = test_create_elem(doc, "TEST");
5846 test_elem_tag((IUnknown*)elem, "TEST");
5847 type = get_node_type((IUnknown*)elem);
5848 ok(type == 1, "type=%d\n", type);
5849 test_ifaces((IUnknown*)elem, elem_iids);
5850 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5852 hres = IHTMLDocument2_get_body(doc, &body);
5853 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5854 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5856 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5857 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5858 elem2 = get_elem_iface((IUnknown*)node);
5859 IHTMLElement_Release(elem2);
5861 hres = IHTMLElement_get_all(body, &disp);
5862 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5863 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5864 IDispatch_Release(disp);
5866 test_node_remove_child((IUnknown*)body, node);
5868 hres = IHTMLElement_get_all(body, &disp);
5869 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5870 test_elem_collection((IUnknown*)disp, NULL, 0);
5871 IDispatch_Release(disp);
5872 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5874 IHTMLElement_Release(elem);
5875 IHTMLDOMNode_Release(node);
5877 node = test_create_text(doc, "test");
5878 test_ifaces((IUnknown*)node, text_iids);
5879 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5880 test_text_length((IUnknown*)node, 4);
5882 V_VT(&var) = VT_NULL;
5883 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5884 IHTMLDOMNode_Release(node);
5886 node = test_create_text(doc, "insert ");
5888 V_VT(&var) = VT_DISPATCH;
5889 V_DISPATCH(&var) = (IDispatch*)node2;
5890 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5891 IHTMLDOMNode_Release(node);
5892 IHTMLDOMNode_Release(node2);
5893 IHTMLDOMNode_Release(node3);
5895 test_elem_innertext(body, "insert test");
5896 test_elem_innerhtml((IUnknown*)body, "insert test");
5898 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5899 if(hres == S_OK)
5901 str = a2bstr("testing");
5902 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5903 SysFreeString(str);
5904 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5905 if(hres == S_OK)
5907 type = get_node_type((IUnknown*)comment);
5908 ok(type == 8, "type=%d, expected 8\n", type);
5910 test_node_get_value_str((IUnknown*)comment, "testing");
5912 IHTMLDOMNode_Release(comment);
5915 IHTMLDocument5_Release(doc5);
5918 IHTMLElement_Release(body);
5921 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5923 IOleCommandTarget *cmdtrg;
5924 HRESULT hres;
5926 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5927 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5929 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5930 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5932 IOleCommandTarget_Release(cmdtrg);
5935 static void test_indent(IHTMLDocument2 *doc)
5937 IHTMLElementCollection *col;
5938 IHTMLTxtRange *range;
5939 HRESULT hres;
5941 static const elem_type_t all_types[] = {
5942 ET_HTML,
5943 ET_HEAD,
5944 ET_TITLE,
5945 ET_BODY,
5946 ET_BR,
5947 ET_A,
5950 static const elem_type_t indent_types[] = {
5951 ET_HTML,
5952 ET_HEAD,
5953 ET_TITLE,
5954 ET_BODY,
5955 ET_BLOCKQUOTE,
5956 ET_P,
5957 ET_BR,
5958 ET_A,
5961 hres = IHTMLDocument2_get_all(doc, &col);
5962 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5963 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5964 IHTMLElementCollection_Release(col);
5966 range = test_create_body_range(doc);
5967 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5968 IHTMLTxtRange_Release(range);
5970 hres = IHTMLDocument2_get_all(doc, &col);
5971 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5972 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5973 IHTMLElementCollection_Release(col);
5976 static void test_cond_comment(IHTMLDocument2 *doc)
5978 IHTMLElementCollection *col;
5979 HRESULT hres;
5981 static const elem_type_t all_types[] = {
5982 ET_HTML,
5983 ET_HEAD,
5984 ET_TITLE,
5985 ET_BODY,
5986 ET_BR
5989 hres = IHTMLDocument2_get_all(doc, &col);
5990 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5991 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5992 IHTMLElementCollection_Release(col);
5995 static void test_frame(IDispatch *disp, const char *exp_id)
5997 IHTMLWindow2 *frame2, *parent, *top;
5998 IHTMLDocument2 *parent_doc, *top_doc;
5999 IHTMLWindow4 *frame;
6000 IHTMLFrameBase *frame_elem;
6001 HRESULT hres;
6003 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
6004 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
6005 if(FAILED(hres))
6006 return;
6008 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
6009 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
6010 IHTMLWindow4_Release(frame);
6011 if(FAILED(hres))
6012 return;
6014 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
6015 test_frame_doc((IUnknown*)frame_elem, FALSE);
6016 test_elem_id((IUnknown*)frame_elem, exp_id);
6017 IHTMLElement_Release(frame_elem);
6019 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
6020 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
6021 if(FAILED(hres))
6022 return;
6024 hres = IHTMLWindow2_get_parent(frame2, &parent);
6025 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
6026 if(FAILED(hres)){
6027 IHTMLWindow2_Release(frame2);
6028 return;
6031 hres = IHTMLWindow2_get_document(parent, &parent_doc);
6032 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6033 IHTMLWindow2_Release(parent);
6034 if(FAILED(hres)){
6035 IHTMLWindow2_Release(frame2);
6036 return;
6039 test_doc_title(parent_doc, "frameset test");
6040 IHTMLDocument2_Release(parent_doc);
6042 /* test get_top */
6043 hres = IHTMLWindow2_get_top(frame2, &top);
6044 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
6045 IHTMLWindow2_Release(frame2);
6046 if(FAILED(hres))
6047 return;
6049 hres = IHTMLWindow2_get_document(top, &top_doc);
6050 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6051 IHTMLWindow2_Release(top);
6052 if(FAILED(hres))
6053 return;
6055 test_doc_title(top_doc, "frameset test");
6056 IHTMLDocument2_Release(top_doc);
6059 static void test_frameset(IHTMLDocument2 *doc)
6061 IHTMLWindow2 *window;
6062 IHTMLFramesCollection2 *frames;
6063 IHTMLElement *elem;
6064 IHTMLFrameBase *fbase;
6065 LONG length;
6066 VARIANT index_var, result_var;
6067 BSTR str;
6068 HRESULT hres;
6070 window = get_doc_window(doc);
6072 /* test using IHTMLFramesCollection object */
6074 hres = IHTMLWindow2_get_frames(window, &frames);
6075 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
6076 IHTMLWindow2_Release(window);
6077 if(FAILED(hres))
6078 return;
6080 /* test result length */
6081 hres = IHTMLFramesCollection2_get_length(frames, &length);
6082 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
6083 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
6085 /* test first frame */
6086 V_VT(&index_var) = VT_I4;
6087 V_I4(&index_var) = 0;
6088 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6089 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6090 if(SUCCEEDED(hres)) {
6091 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6092 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6094 VariantClear(&result_var);
6096 /* test second frame */
6097 V_I4(&index_var) = 1;
6098 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6099 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6100 if(SUCCEEDED(hres)) {
6101 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6102 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6104 VariantClear(&result_var);
6106 /* fail on next frame */
6107 V_I4(&index_var) = 3;
6108 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6109 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
6110 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6111 VariantClear(&result_var);
6113 /* string argument (element id lookup) */
6114 V_VT(&index_var) = VT_BSTR;
6115 V_BSTR(&index_var) = a2bstr("fr1");
6116 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6117 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6118 if(SUCCEEDED(hres)) {
6119 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6120 test_frame(V_DISPATCH(&result_var), "fr1");
6122 VariantClear(&result_var);
6123 VariantClear(&index_var);
6125 /* invalid argument */
6126 V_VT(&index_var) = VT_BOOL;
6127 V_BOOL(&index_var) = VARIANT_TRUE;
6128 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6129 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
6130 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6131 VariantClear(&result_var);
6133 IHTMLFramesCollection2_Release(frames);
6135 /* test using IHTMLWindow2 inheritance */
6137 /* test result length */
6138 hres = IHTMLWindow2_get_length(window, &length);
6139 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
6140 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
6142 /* test first frame */
6143 V_VT(&index_var) = VT_I4;
6144 V_I4(&index_var) = 0;
6145 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6146 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6147 if(SUCCEEDED(hres)) {
6148 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6149 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6151 VariantClear(&result_var);
6153 /* test second frame */
6154 V_I4(&index_var) = 1;
6155 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6156 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6157 if(SUCCEEDED(hres)) {
6158 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6159 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6161 VariantClear(&result_var);
6163 /* fail on next frame */
6164 V_I4(&index_var) = 3;
6165 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6166 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
6167 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6168 VariantClear(&result_var);
6170 /* string argument (element id lookup) */
6171 V_VT(&index_var) = VT_BSTR;
6172 V_BSTR(&index_var) = a2bstr("fr2");
6173 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6174 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6175 if(SUCCEEDED(hres)) {
6176 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6177 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6179 VariantClear(&result_var);
6180 VariantClear(&index_var);
6182 /* invalid argument */
6183 V_VT(&index_var) = VT_BOOL;
6184 V_BOOL(&index_var) = VARIANT_TRUE;
6185 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6186 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
6187 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6188 VariantClear(&result_var);
6190 /* getElementById with node name attributes */
6191 elem = get_doc_elem_by_id(doc, "nm1");
6192 test_elem_id((IUnknown*)elem, "fr1");
6194 /* get/put scrolling */
6195 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6196 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6198 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6199 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6200 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
6201 SysFreeString(str);
6203 str = a2bstr("no");
6204 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6205 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
6206 SysFreeString(str);
6208 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6209 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6210 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6211 SysFreeString(str);
6213 str = a2bstr("junk");
6214 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6215 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
6216 "with E_INVALIDARG, instead: 0x%08x\n", hres);
6217 SysFreeString(str);
6219 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6220 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6221 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6222 SysFreeString(str);
6224 /* get_name */
6225 hres = IHTMLFrameBase_get_name(fbase, &str);
6226 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6227 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
6228 SysFreeString(str);
6230 IHTMLFrameBase_Release(fbase);
6231 IHTMLElement_Release(elem);
6233 /* get_name with no name attr */
6234 elem = get_doc_elem_by_id(doc, "fr3");
6235 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6236 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6238 hres = IHTMLFrameBase_get_name(fbase, &str);
6239 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6240 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
6241 SysFreeString(str);
6243 IHTMLFrameBase_Release(fbase);
6244 IHTMLElement_Release(elem);
6247 static IHTMLDocument2 *notif_doc;
6248 static BOOL doc_complete;
6250 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
6251 REFIID riid, void**ppv)
6253 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
6254 *ppv = iface;
6255 return S_OK;
6258 ok(0, "unexpected call\n");
6259 return E_NOINTERFACE;
6262 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
6264 return 2;
6267 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
6269 return 1;
6272 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
6274 if(dispID == DISPID_READYSTATE){
6275 BSTR state;
6276 HRESULT hres;
6278 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
6279 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
6281 if(!strcmp_wa(state, "complete"))
6282 doc_complete = TRUE;
6284 SysFreeString(state);
6287 return S_OK;
6290 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
6292 ok(0, "unexpected call\n");
6293 return E_NOTIMPL;
6296 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
6297 PropertyNotifySink_QueryInterface,
6298 PropertyNotifySink_AddRef,
6299 PropertyNotifySink_Release,
6300 PropertyNotifySink_OnChanged,
6301 PropertyNotifySink_OnRequestEdit
6304 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
6306 static IHTMLDocument2 *create_doc_with_string(const char *str)
6308 IPersistStreamInit *init;
6309 IStream *stream;
6310 IHTMLDocument2 *doc;
6311 HGLOBAL mem;
6312 SIZE_T len;
6314 notif_doc = doc = create_document();
6315 if(!doc)
6316 return NULL;
6318 doc_complete = FALSE;
6319 len = strlen(str);
6320 mem = GlobalAlloc(0, len);
6321 memcpy(mem, str, len);
6322 CreateStreamOnHGlobal(mem, TRUE, &stream);
6324 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
6326 IPersistStreamInit_Load(init, stream);
6327 IPersistStreamInit_Release(init);
6328 IStream_Release(stream);
6330 return doc;
6333 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
6335 IConnectionPointContainer *container;
6336 IConnectionPoint *cp;
6337 DWORD cookie;
6338 HRESULT hres;
6340 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
6341 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
6343 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
6344 IConnectionPointContainer_Release(container);
6345 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
6347 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
6348 IConnectionPoint_Release(cp);
6349 ok(hres == S_OK, "Advise failed: %08x\n", hres);
6352 typedef void (*domtest_t)(IHTMLDocument2*);
6354 static void run_domtest(const char *str, domtest_t test)
6356 IHTMLDocument2 *doc;
6357 ULONG ref;
6358 MSG msg;
6360 doc = create_doc_with_string(str);
6361 if(!doc)
6362 return;
6364 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
6366 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
6367 TranslateMessage(&msg);
6368 DispatchMessage(&msg);
6371 test(doc);
6373 ref = IHTMLDocument2_Release(doc);
6374 ok(!ref ||
6375 ref == 1, /* Vista */
6376 "ref = %d\n", ref);
6379 START_TEST(dom)
6381 CoInitialize(NULL);
6383 run_domtest(doc_str1, test_doc_elem);
6384 run_domtest(doc_str1, test_get_set_attr);
6385 run_domtest(range_test_str, test_txtrange);
6386 run_domtest(range_test2_str, test_txtrange2);
6387 if (winetest_interactive || ! is_ie_hardened()) {
6388 run_domtest(elem_test_str, test_elems);
6389 }else {
6390 skip("IE running in Enhanced Security Configuration\n");
6392 run_domtest(elem_test2_str, test_elems2);
6393 run_domtest(doc_blank, test_create_elems);
6394 run_domtest(doc_blank, test_defaults);
6395 run_domtest(indent_test_str, test_indent);
6396 run_domtest(cond_comment_str, test_cond_comment);
6397 run_domtest(frameset_str, test_frameset);
6399 CoUninitialize();