c13c0a8c6067b3a2eb7e14d8d288a9da74771a39
[reactos.git] / rostests / winetests / mshtml / dom.c
1 /*
2 * Copyright 2007-2008 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #define COBJMACROS
20 #define CONST_VTABLE
21
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
25
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"
35
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\"/>"
53 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
54 "</body></html>";
55 static const char indent_test_str[] =
56 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
57 static const char cond_comment_str[] =
58 "<html><head><title>test</title></head><body>"
59 "<!--[if gte IE 4]> <br> <![endif]-->"
60 "</body></html>";
61
62 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
63 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
64 static WCHAR wordW[] = {'w','o','r','d',0};
65
66 typedef enum {
67 ET_NONE,
68 ET_HTML,
69 ET_HEAD,
70 ET_TITLE,
71 ET_BODY,
72 ET_A,
73 ET_INPUT,
74 ET_SELECT,
75 ET_TEXTAREA,
76 ET_OPTION,
77 ET_STYLE,
78 ET_BLOCKQUOTE,
79 ET_P,
80 ET_BR,
81 ET_TABLE,
82 ET_TBODY,
83 ET_SCRIPT,
84 ET_TEST,
85 ET_TESTG,
86 ET_COMMENT,
87 ET_IMG,
88 ET_TR,
89 ET_TD,
90 ET_IFRAME
91 } elem_type_t;
92
93 static const IID * const none_iids[] = {
94 &IID_IUnknown,
95 NULL
96 };
97
98 static const IID * const doc_node_iids[] = {
99 &IID_IHTMLDOMNode,
100 &IID_IHTMLDOMNode2,
101 &IID_IHTMLDocument,
102 &IID_IHTMLDocument2,
103 &IID_IHTMLDocument3,
104 &IID_IHTMLDocument4,
105 &IID_IHTMLDocument5,
106 &IID_IDispatchEx,
107 &IID_IConnectionPointContainer,
108 &IID_IInternetHostSecurityManager,
109 NULL
110 };
111
112 static const IID * const doc_obj_iids[] = {
113 &IID_IHTMLDocument,
114 &IID_IHTMLDocument2,
115 &IID_IHTMLDocument3,
116 &IID_IHTMLDocument4,
117 &IID_IHTMLDocument5,
118 &IID_IDispatchEx,
119 &IID_IConnectionPointContainer,
120 &IID_ICustomDoc,
121 NULL
122 };
123
124 static const IID * const elem_iids[] = {
125 &IID_IHTMLDOMNode,
126 &IID_IHTMLDOMNode2,
127 &IID_IHTMLElement,
128 &IID_IHTMLElement2,
129 &IID_IHTMLElement3,
130 &IID_IDispatchEx,
131 &IID_IConnectionPointContainer,
132 NULL
133 };
134
135 static const IID * const body_iids[] = {
136 &IID_IHTMLDOMNode,
137 &IID_IHTMLDOMNode2,
138 &IID_IHTMLElement,
139 &IID_IHTMLElement2,
140 &IID_IHTMLElement3,
141 &IID_IHTMLTextContainer,
142 &IID_IHTMLBodyElement,
143 &IID_IDispatchEx,
144 &IID_IConnectionPointContainer,
145 NULL
146 };
147
148 static const IID * const anchor_iids[] = {
149 &IID_IHTMLDOMNode,
150 &IID_IHTMLDOMNode2,
151 &IID_IHTMLElement,
152 &IID_IHTMLElement2,
153 &IID_IHTMLElement3,
154 &IID_IHTMLAnchorElement,
155 &IID_IDispatchEx,
156 &IID_IConnectionPointContainer,
157 NULL
158 };
159
160 static const IID * const input_iids[] = {
161 &IID_IHTMLDOMNode,
162 &IID_IHTMLDOMNode2,
163 &IID_IHTMLElement,
164 &IID_IHTMLElement2,
165 &IID_IHTMLElement3,
166 &IID_IHTMLInputElement,
167 &IID_IHTMLInputTextElement,
168 &IID_IDispatchEx,
169 &IID_IConnectionPointContainer,
170 NULL
171 };
172
173 static const IID * const select_iids[] = {
174 &IID_IHTMLDOMNode,
175 &IID_IHTMLDOMNode2,
176 &IID_IHTMLElement,
177 &IID_IHTMLElement2,
178 &IID_IHTMLElement3,
179 &IID_IHTMLSelectElement,
180 &IID_IDispatchEx,
181 &IID_IConnectionPointContainer,
182 NULL
183 };
184
185 static const IID * const textarea_iids[] = {
186 &IID_IHTMLDOMNode,
187 &IID_IHTMLDOMNode2,
188 &IID_IHTMLElement,
189 &IID_IHTMLElement2,
190 &IID_IHTMLElement3,
191 &IID_IHTMLTextAreaElement,
192 &IID_IDispatchEx,
193 &IID_IConnectionPointContainer,
194 NULL
195 };
196
197 static const IID * const option_iids[] = {
198 &IID_IHTMLDOMNode,
199 &IID_IHTMLDOMNode2,
200 &IID_IHTMLElement,
201 &IID_IHTMLElement2,
202 &IID_IHTMLElement3,
203 &IID_IHTMLOptionElement,
204 &IID_IDispatchEx,
205 &IID_IConnectionPointContainer,
206 NULL
207 };
208
209 static const IID * const table_iids[] = {
210 &IID_IHTMLDOMNode,
211 &IID_IHTMLDOMNode2,
212 &IID_IHTMLElement,
213 &IID_IHTMLElement2,
214 &IID_IHTMLElement3,
215 &IID_IHTMLTable,
216 &IID_IDispatchEx,
217 &IID_IConnectionPointContainer,
218 NULL
219 };
220
221 static const IID * const script_iids[] = {
222 &IID_IHTMLDOMNode,
223 &IID_IHTMLDOMNode2,
224 &IID_IHTMLElement,
225 &IID_IHTMLElement2,
226 &IID_IHTMLElement3,
227 &IID_IHTMLScriptElement,
228 &IID_IDispatchEx,
229 &IID_IConnectionPointContainer,
230 NULL
231 };
232
233 static const IID * const text_iids[] = {
234 &IID_IHTMLDOMNode,
235 &IID_IHTMLDOMNode2,
236 &IID_IHTMLDOMTextNode,
237 NULL
238 };
239
240 static const IID * const location_iids[] = {
241 &IID_IDispatch,
242 &IID_IHTMLLocation,
243 NULL
244 };
245
246 static const IID * const window_iids[] = {
247 &IID_IDispatch,
248 &IID_IHTMLWindow2,
249 &IID_IHTMLWindow3,
250 &IID_IDispatchEx,
251 NULL
252 };
253
254 static const IID * const comment_iids[] = {
255 &IID_IHTMLDOMNode,
256 &IID_IHTMLDOMNode2,
257 &IID_IHTMLElement,
258 &IID_IHTMLElement2,
259 &IID_IHTMLElement3,
260 &IID_IHTMLCommentElement,
261 &IID_IDispatchEx,
262 &IID_IConnectionPointContainer,
263 NULL
264 };
265
266 static const IID * const img_iids[] = {
267 &IID_IHTMLDOMNode,
268 &IID_IHTMLDOMNode2,
269 &IID_IHTMLElement,
270 &IID_IHTMLElement2,
271 &IID_IHTMLElement3,
272 &IID_IDispatchEx,
273 &IID_IHTMLImgElement,
274 &IID_IConnectionPointContainer,
275 NULL
276 };
277
278 static const IID * const tr_iids[] = {
279 &IID_IHTMLDOMNode,
280 &IID_IHTMLDOMNode2,
281 &IID_IHTMLElement,
282 &IID_IHTMLElement2,
283 &IID_IHTMLElement3,
284 &IID_IDispatchEx,
285 &IID_IHTMLTableRow,
286 &IID_IConnectionPointContainer,
287 NULL
288 };
289
290 static const IID * const td_iids[] = {
291 &IID_IHTMLDOMNode,
292 &IID_IHTMLDOMNode2,
293 &IID_IHTMLElement,
294 &IID_IHTMLElement2,
295 &IID_IHTMLElement3,
296 &IID_IDispatchEx,
297 &IID_IConnectionPointContainer,
298 NULL
299 };
300
301 static const IID * const iframe_iids[] = {
302 &IID_IHTMLDOMNode,
303 &IID_IHTMLDOMNode2,
304 &IID_IHTMLElement,
305 &IID_IHTMLElement2,
306 &IID_IHTMLElement3,
307 &IID_IHTMLFrameBase2,
308 &IID_IDispatchEx,
309 &IID_IConnectionPointContainer,
310 NULL
311 };
312
313 static const IID * const generic_iids[] = {
314 &IID_IHTMLDOMNode,
315 &IID_IHTMLDOMNode2,
316 &IID_IHTMLElement,
317 &IID_IHTMLElement2,
318 &IID_IHTMLElement3,
319 &IID_IHTMLGenericElement,
320 &IID_IDispatchEx,
321 &IID_IConnectionPointContainer,
322 NULL
323 };
324
325 static const IID * const style_iids[] = {
326 &IID_IUnknown,
327 &IID_IDispatch,
328 &IID_IDispatchEx,
329 &IID_IHTMLStyle,
330 &IID_IHTMLStyle2,
331 &IID_IHTMLStyle3,
332 &IID_IHTMLStyle4,
333 NULL
334 };
335
336 static const IID * const cstyle_iids[] = {
337 &IID_IUnknown,
338 &IID_IDispatch,
339 &IID_IDispatchEx,
340 &IID_IHTMLCurrentStyle,
341 NULL
342 };
343
344 typedef struct {
345 const char *tag;
346 REFIID *iids;
347 const IID *dispiid;
348 } elem_type_info_t;
349
350 static const elem_type_info_t elem_type_infos[] = {
351 {"", none_iids, NULL},
352 {"HTML", elem_iids, NULL},
353 {"HEAD", elem_iids, NULL},
354 {"TITLE", elem_iids, NULL},
355 {"BODY", body_iids, &DIID_DispHTMLBody},
356 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
357 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
358 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
359 {"TEXTAREA", textarea_iids, NULL},
360 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
361 {"STYLE", elem_iids, NULL},
362 {"BLOCKQUOTE",elem_iids, NULL},
363 {"P", elem_iids, NULL},
364 {"BR", elem_iids, NULL},
365 {"TABLE", table_iids, &DIID_DispHTMLTable},
366 {"TBODY", elem_iids, NULL},
367 {"SCRIPT", script_iids, NULL},
368 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
369 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
370 {"!", comment_iids, &DIID_DispHTMLCommentElement},
371 {"IMG", img_iids, &DIID_DispHTMLImg},
372 {"TR", tr_iids, &DIID_DispHTMLTableRow},
373 {"TD", td_iids, NULL},
374 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}
375 };
376
377 static const char *dbgstr_guid(REFIID riid)
378 {
379 static char buf[50];
380
381 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
382 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
383 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
384 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
385
386 return buf;
387 }
388
389 static int strcmp_wa(LPCWSTR strw, const char *stra)
390 {
391 CHAR buf[512];
392 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
393 return lstrcmpA(stra, buf);
394 }
395
396 static BSTR a2bstr(const char *str)
397 {
398 BSTR ret;
399 int len;
400
401 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
402 ret = SysAllocStringLen(NULL, len);
403 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
404
405 return ret;
406 }
407
408 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
409 {
410 IUnknown *unk1, *unk2;
411
412 if(iface1 == iface2)
413 return TRUE;
414
415 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
416 IUnknown_Release(unk1);
417 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
418 IUnknown_Release(unk2);
419
420 return unk1 == unk2;
421 }
422
423 static IHTMLDocument2 *create_document(void)
424 {
425 IHTMLDocument2 *doc;
426 IHTMLDocument5 *doc5;
427 HRESULT hres;
428
429 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
430 &IID_IHTMLDocument2, (void**)&doc);
431 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
432
433 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
434 if(FAILED(hres)) {
435 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
436 IHTMLDocument2_Release(doc);
437 return NULL;
438 }
439
440 IHTMLDocument5_Release(doc5);
441 return doc;
442 }
443
444 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
445 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
446 {
447 const IID * const *piid;
448 IUnknown *unk;
449 HRESULT hres;
450
451 for(piid = iids; *piid; piid++) {
452 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
453 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
454 if(SUCCEEDED(hres))
455 IUnknown_Release(unk);
456 }
457 }
458
459 #define test_get_dispid(u,id) _test_disp(__LINE__,u,id)
460 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
461 {
462 IDispatchEx *dispex;
463 ITypeInfo *typeinfo;
464 BOOL ret = FALSE;
465 UINT ticnt;
466 HRESULT hres;
467
468 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
469 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
470 if(FAILED(hres))
471 return FALSE;
472
473 ticnt = 0xdeadbeef;
474 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
475 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
476 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
477
478 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
479 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
480
481 if(SUCCEEDED(hres)) {
482 TYPEATTR *type_attr;
483
484 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
485 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
486 if(hres == S_OK) {
487 *iid = type_attr->guid;
488 ret = TRUE;
489 }
490
491 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
492 ITypeInfo_Release(typeinfo);
493 }
494
495 IDispatchEx_Release(dispex);
496 return ret;
497 }
498
499 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
500 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
501 {
502 DISPPARAMS dp = {NULL,NULL,0,0};
503 IDispatchEx *dispex;
504 EXCEPINFO ei;
505 VARIANT var;
506 HRESULT hres;
507
508 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
509 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
510 if(FAILED(hres))
511 return;
512
513 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
514 IDispatchEx_Release(dispex);
515 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
516
517 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
518 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
519 VariantClear(&var);
520 }
521
522 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
523 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
524 {
525 IID iid;
526
527 if(_test_get_dispid(line, unk, &iid))
528 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
529
530 if(val)
531 _test_disp_value(line, unk, val);
532 }
533
534 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
535 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
536 {
537 IID iid;
538
539 if(_test_get_dispid(line, unk, &iid))
540 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
541 "unexpected guid %s\n", dbgstr_guid(&iid));
542
543 if(val)
544 _test_disp_value(line, unk, val);
545 }
546
547 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
548 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
549 {
550 IHTMLElement *elem;
551 HRESULT hres;
552
553 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
554 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
555 return elem;
556 }
557
558 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
559 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
560 {
561 IHTMLElement2 *elem;
562 HRESULT hres;
563
564 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
565 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
566 return elem;
567 }
568
569 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
570 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
571 {
572 IHTMLElement3 *elem;
573 HRESULT hres;
574
575 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
576 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
577 return elem;
578 }
579
580 #define get_node_iface(u) _get_node_iface(__LINE__,u)
581 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
582 {
583 IHTMLDOMNode *node;
584 HRESULT hres;
585
586 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
587 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
588 return node;
589 }
590
591 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
592 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
593 {
594 IHTMLDOMNode2 *node;
595 HRESULT hres;
596
597 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
598 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
599 return node;
600 }
601
602 #define get_img_iface(u) _get_img_iface(__LINE__,u)
603 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
604 {
605 IHTMLImgElement *img;
606 HRESULT hres;
607
608 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
609 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
610 return img;
611 }
612
613 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
614 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
615 {
616 IHTMLAnchorElement *anchor;
617 HRESULT hres;
618
619 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
620 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
621 return anchor;
622 }
623
624 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
625 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
626 {
627 IHTMLDOMNode *node = _get_node_iface(line, unk);
628 BSTR name;
629 HRESULT hres;
630
631 hres = IHTMLDOMNode_get_nodeName(node, &name);
632 IHTMLDOMNode_Release(node);
633 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
634 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
635
636 SysFreeString(name);
637 }
638
639 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
640 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
641 {
642 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
643 IDispatch *disp = (void*)0xdeadbeef;
644 IHTMLDocument2 *doc;
645 HRESULT hres;
646
647 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
648 IHTMLDOMNode2_Release(node);
649 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
650 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
651
652 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
653 IDispatch_Release(disp);
654 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
655
656 return doc;
657 }
658
659 #define clone_node(n,d) _clone_node(__LINE__,n,d)
660 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
661 {
662 IHTMLDOMNode *node = _get_node_iface(line, unk);
663 IHTMLDOMNode *ret = NULL;
664 HRESULT hres;
665
666 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
667 IHTMLDOMNode_Release(node);
668 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
669 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
670
671 return ret;
672
673 }
674
675 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
676 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
677 {
678 IHTMLElement *elem = _get_elem_iface(line, unk);
679 BSTR tag;
680 HRESULT hres;
681
682 hres = IHTMLElement_get_tagName(elem, &tag);
683 IHTMLElement_Release(elem);
684 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
685 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
686
687 SysFreeString(tag);
688 }
689
690 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
691 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
692 {
693 _test_elem_tag(line, unk, elem_type_infos[type].tag);
694 _test_ifaces(line, unk, elem_type_infos[type].iids);
695
696 if(elem_type_infos[type].dispiid && type != ET_A)
697 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
698 }
699
700 #define get_node_type(n) _get_node_type(__LINE__,n)
701 static LONG _get_node_type(unsigned line, IUnknown *unk)
702 {
703 IHTMLDOMNode *node = _get_node_iface(line, unk);
704 LONG type = -1;
705 HRESULT hres;
706
707 hres = IHTMLDOMNode_get_nodeType(node, &type);
708 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
709
710 IHTMLDOMNode_Release(node);
711
712 return type;
713 }
714
715 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
716 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
717 {
718 IHTMLDOMNode *node = _get_node_iface(line, unk);
719 IHTMLDOMChildrenCollection *col = NULL;
720 IDispatch *disp;
721 HRESULT hres;
722
723 hres = IHTMLDOMNode_get_childNodes(node, &disp);
724 IHTMLDOMNode_Release(node);
725 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
726 if(FAILED(hres))
727 return NULL;
728
729 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
730 IDispatch_Release(disp);
731 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
732
733 return col;
734 }
735
736 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
737 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
738 {
739 IHTMLDOMNode *node = NULL;
740 IDispatch *disp;
741 HRESULT hres;
742
743 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
744 ok(hres == S_OK, "item failed: %08x\n", hres);
745
746 node = _get_node_iface(line, (IUnknown*)disp);
747 IDispatch_Release(disp);
748
749 return node;
750 }
751
752 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
753 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
754 {
755 VARIANT value;
756 BSTR tmp;
757 HRESULT hres;
758
759 VariantInit(&value);
760
761 tmp = a2bstr(name);
762 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
763 SysFreeString(tmp);
764 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
765
766 if(exval) {
767 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
768 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
769 }else {
770 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
771 }
772
773 VariantClear(&value);
774 }
775
776 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
777 static void _test_elem_offset(unsigned line, IUnknown *unk)
778 {
779 IHTMLElement *elem = _get_elem_iface(line, unk);
780 LONG l;
781 HRESULT hres;
782
783 hres = IHTMLElement_get_offsetTop(elem, &l);
784 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
785
786 hres = IHTMLElement_get_offsetHeight(elem, &l);
787 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
788
789 hres = IHTMLElement_get_offsetWidth(elem, &l);
790 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
791
792 IHTMLElement_Release(elem);
793 }
794
795 #define get_doc_node(d) _get_doc_node(__LINE__,d)
796 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
797 {
798 IHTMLWindow2 *window;
799 IHTMLDocument2 *ret;
800 HRESULT hres;
801
802 hres = IHTMLDocument2_get_parentWindow(doc, &window);
803 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
804
805 hres = IHTMLWindow2_get_document(window, &ret);
806 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
807 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
808
809 return ret;
810 }
811
812 static void test_get_set_attr(IHTMLDocument2 *doc)
813 {
814 IHTMLElement *elem;
815 IHTMLDocument3 *doc3;
816 HRESULT hres;
817 BSTR bstr;
818 VARIANT val;
819
820 /* grab an element to test with */
821 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
822 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
823
824 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
825 IHTMLDocument3_Release(doc3);
826 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
827
828 /* get a non-present attribute */
829 bstr = a2bstr("notAnAttribute");
830 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
831 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
832 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
833 VariantClear(&val);
834 SysFreeString(bstr);
835
836 /* get a present attribute */
837 bstr = a2bstr("scrollHeight");
838 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
839 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
840 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
841 VariantClear(&val);
842 SysFreeString(bstr);
843
844 /* create a new BSTR attribute */
845 bstr = a2bstr("newAttribute");
846
847 V_VT(&val) = VT_BSTR;
848 V_BSTR(&val) = a2bstr("the value");
849 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
850 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
851 VariantClear(&val);
852
853 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
854 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
855 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
856 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)));
857 VariantClear(&val);
858
859 /* overwrite the attribute with a BOOL */
860 V_VT(&val) = VT_BOOL;
861 V_BOOL(&val) = VARIANT_TRUE;
862 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
863 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
864 VariantClear(&val);
865
866 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
867 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
868 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
869 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
870 VariantClear(&val);
871
872 SysFreeString(bstr);
873
874 /* case-insensitive */
875 bstr = a2bstr("newattribute");
876 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
877 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
878 todo_wine ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
879 todo_wine ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
880 VariantClear(&val);
881 SysFreeString(bstr);
882
883 IHTMLElement_Release(elem);
884 }
885
886 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
887 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
888 {
889 IHTMLElement *elem;
890 IHTMLDocument3 *doc3;
891 HRESULT hres;
892
893 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
894 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
895 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
896 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
897 IHTMLDocument3_Release(doc3);
898
899 return elem;
900 }
901
902 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
903 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
904 {
905 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
906 BSTR str;
907 HRESULT hres;
908
909 hres = IHTMLAnchorElement_get_href(anchor, &str);
910 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
911 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
912 SysFreeString(str);
913
914 _test_disp_value(line, unk, exhref);
915 }
916
917 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
918 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
919 {
920 BSTR bstr;
921 HRESULT hres;
922
923 hres = IHTMLOptionElement_get_text(option, &bstr);
924 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
925 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
926 SysFreeString(bstr);
927 }
928
929 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
930 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
931 {
932 BSTR bstr;
933 HRESULT hres;
934
935 bstr = a2bstr(text);
936 hres = IHTMLOptionElement_put_text(option, bstr);
937 SysFreeString(bstr);
938 ok(hres == S_OK, "put_text failed: %08x\n", hres);
939
940 _test_option_text(line, option, text);
941 }
942
943 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
944 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
945 {
946 BSTR bstr;
947 HRESULT hres;
948
949 hres = IHTMLOptionElement_get_value(option, &bstr);
950 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
951 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
952 SysFreeString(bstr);
953 }
954
955 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
956 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
957 {
958 BSTR bstr;
959 HRESULT hres;
960
961 bstr = a2bstr(value);
962 hres = IHTMLOptionElement_put_value(option, bstr);
963 SysFreeString(bstr);
964 ok(hres == S_OK, "put_value failed: %08x\n", hres);
965
966 _test_option_value(line, option, value);
967 }
968
969 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
970 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
971 const char *txt, const char *val)
972 {
973 IHTMLOptionElementFactory *factory;
974 IHTMLOptionElement *option;
975 IHTMLWindow2 *window;
976 VARIANT text, value, empty;
977 HRESULT hres;
978
979 hres = IHTMLDocument2_get_parentWindow(doc, &window);
980 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
981
982 hres = IHTMLWindow2_get_Option(window, &factory);
983 IHTMLWindow2_Release(window);
984 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
985
986 V_VT(&text) = VT_BSTR;
987 V_BSTR(&text) = a2bstr(txt);
988 V_VT(&value) = VT_BSTR;
989 V_BSTR(&value) = a2bstr(val);
990 V_VT(&empty) = VT_EMPTY;
991
992 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
993 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
994
995 IHTMLOptionElementFactory_Release(factory);
996 VariantClear(&text);
997 VariantClear(&value);
998
999 _test_option_text(line, option, txt);
1000 _test_option_value(line, option, val);
1001
1002 return option;
1003 }
1004
1005 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1006 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1007 {
1008 LONG len = 0xdeadbeef;
1009 HRESULT hres;
1010
1011 hres = IHTMLSelectElement_get_length(select, &len);
1012 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1013 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1014 }
1015
1016 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1017 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1018 {
1019 LONG idx = 0xdeadbeef;
1020 HRESULT hres;
1021
1022 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1023 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1024 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1025 }
1026
1027 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1028 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1029 {
1030 HRESULT hres;
1031
1032 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1033 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1034 _test_select_selidx(line, select, index);
1035 }
1036
1037 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1038 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1039 {
1040 BSTR val;
1041 HRESULT hres;
1042
1043 hres = IHTMLSelectElement_get_value(select, &val);
1044 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1045 if(exval)
1046 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1047 else
1048 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1049 }
1050
1051 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1052 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1053 {
1054 BSTR bstr;
1055 HRESULT hres;
1056
1057 bstr = a2bstr(val);
1058 hres = IHTMLSelectElement_put_value(select, bstr);
1059 SysFreeString(bstr);
1060 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1061 }
1062
1063 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1064 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1065 {
1066 BSTR type;
1067 HRESULT hres;
1068
1069 hres = IHTMLSelectElement_get_type(select, &type);
1070 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1071 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1072 }
1073
1074 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1075 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1076 {
1077 BSTR text;
1078 HRESULT hres;
1079
1080 hres = IHTMLTxtRange_get_text(range, &text);
1081 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1082
1083 if(extext) {
1084 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1085 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1086 }else {
1087 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1088 }
1089
1090 SysFreeString(text);
1091
1092 }
1093
1094 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1095 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1096 {
1097 HRESULT hres;
1098
1099 hres = IHTMLTxtRange_collapse(range, b);
1100 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1101 _test_range_text(line, range, NULL);
1102 }
1103
1104 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1105 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1106 VARIANT_BOOL exb, const char *extext)
1107 {
1108 VARIANT_BOOL b = 0xe0e0;
1109 HRESULT hres;
1110
1111 hres = IHTMLTxtRange_expand(range, unit, &b);
1112 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1113 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1114 _test_range_text(line, range, extext);
1115 }
1116
1117 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1118 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1119 {
1120 LONG c = 0xdeadbeef;
1121 HRESULT hres;
1122
1123 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1124 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1125 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1126 _test_range_text(line, range, NULL);
1127 }
1128
1129 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1130 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1131 LPWSTR unit, LONG cnt, LONG excnt)
1132 {
1133 LONG c = 0xdeadbeef;
1134 HRESULT hres;
1135
1136 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1137 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1138 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1139 }
1140
1141 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1142 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1143 {
1144 LONG c = 0xdeadbeef;
1145 HRESULT hres;
1146
1147 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1148 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1149 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1150 }
1151
1152 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1153 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1154 {
1155 HRESULT hres;
1156 BSTR bstr = a2bstr(text);
1157
1158 hres = IHTMLTxtRange_put_text(range, bstr);
1159 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1160 SysFreeString(bstr);
1161 _test_range_text(line, range, NULL);
1162 }
1163
1164 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1165 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1166 {
1167 VARIANT_BOOL b;
1168 HRESULT hres;
1169
1170 b = 0xe0e0;
1171 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1172 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1173 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1174 }
1175
1176 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1177 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1178 {
1179 VARIANT_BOOL b;
1180 HRESULT hres;
1181
1182 b = 0xe0e0;
1183 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1184 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1185 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1186
1187 b = 0xe0e0;
1188 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1189 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1190 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1191
1192 if(exb) {
1193 test_range_inrange(range1, range2, VARIANT_TRUE);
1194 test_range_inrange(range2, range1, VARIANT_TRUE);
1195 }
1196 }
1197
1198 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1199 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1200 {
1201 IHTMLElement *elem;
1202 HRESULT hres;
1203
1204 hres = IHTMLTxtRange_parentElement(range, &elem);
1205 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1206
1207 _test_elem_type(line, (IUnknown*)elem, type);
1208
1209 IHTMLElement_Release(elem);
1210 }
1211
1212 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1213 static void _test_elem_collection(unsigned line, IUnknown *unk,
1214 const elem_type_t *elem_types, LONG exlen)
1215 {
1216 IHTMLElementCollection *col;
1217 LONG len;
1218 DWORD i;
1219 VARIANT name, index;
1220 IDispatch *disp, *disp2;
1221 HRESULT hres;
1222
1223 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1224 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1225
1226 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1227
1228 hres = IHTMLElementCollection_get_length(col, &len);
1229 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1230 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1231
1232 if(len > exlen)
1233 len = exlen;
1234
1235 V_VT(&index) = VT_EMPTY;
1236
1237 for(i=0; i<len; i++) {
1238 V_VT(&name) = VT_I4;
1239 V_I4(&name) = i;
1240 disp = (void*)0xdeadbeef;
1241 hres = IHTMLElementCollection_item(col, name, index, &disp);
1242 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1243 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1244 if(FAILED(hres) || !disp)
1245 continue;
1246
1247 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1248
1249 if(!i) {
1250 V_VT(&name) = VT_UINT;
1251 V_I4(&name) = 0;
1252 disp2 = (void*)0xdeadbeef;
1253 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1254 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1255 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1256 if(disp2)
1257 IDispatch_Release(disp2);
1258 }
1259
1260 IDispatch_Release(disp);
1261 }
1262
1263 V_VT(&name) = VT_I4;
1264 V_I4(&name) = len;
1265 disp = (void*)0xdeadbeef;
1266 hres = IHTMLElementCollection_item(col, name, index, &disp);
1267 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1268 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1269
1270 V_VT(&name) = VT_I4;
1271 V_I4(&name) = -1;
1272 disp = (void*)0xdeadbeef;
1273 hres = IHTMLElementCollection_item(col, name, index, &disp);
1274 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1275 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1276
1277 IHTMLElementCollection_Release(col);
1278 }
1279
1280 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1281 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1282 {
1283 IHTMLElement *elem = _get_elem_iface(line, unk);
1284 IDispatch *disp;
1285 HRESULT hres;
1286
1287 hres = IHTMLElement_get_all(elem, &disp);
1288 IHTMLElement_Release(elem);
1289 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1290
1291 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1292 IDispatch_Release(disp);
1293 }
1294
1295 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1296 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1297 {
1298 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1299 IHTMLElementCollection *col = NULL;
1300 elem_type_t *types = NULL;
1301 BSTR tmp;
1302 int i;
1303 HRESULT hres;
1304
1305 tmp = a2bstr(elem_type_infos[type].tag);
1306 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1307 SysFreeString(tmp);
1308 IHTMLElement2_Release(elem);
1309 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1310 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1311
1312 if(exlen) {
1313 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1314 for(i=0; i<exlen; i++)
1315 types[i] = type;
1316 }
1317
1318 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1319
1320 HeapFree(GetProcessHeap(), 0, types);
1321 }
1322
1323 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1324 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1325 {
1326 BSTR text = NULL;
1327 HRESULT hres;
1328
1329 hres = IHTMLElement_get_innerText(elem, &text);
1330 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1331 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1332 wine_dbgstr_w(text), extext);
1333 SysFreeString(text);
1334 }
1335
1336 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1337 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1338 {
1339 IHTMLDOMChildrenCollection *col;
1340 BSTR str;
1341 HRESULT hres;
1342
1343 str = a2bstr(text);
1344 hres = IHTMLElement_put_innerText(elem, str);
1345 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1346 SysFreeString(str);
1347
1348 _test_elem_innertext(line, elem, text);
1349
1350
1351 col = _get_child_nodes(line, (IUnknown*)elem);
1352 ok(col != NULL, "col == NULL\n");
1353 if(col) {
1354 LONG length = 0, type;
1355 IHTMLDOMNode *node;
1356
1357 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1358 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1359 ok(length == 1, "length = %d\n", length);
1360
1361 node = _get_child_item(line, col, 0);
1362 ok(node != NULL, "node == NULL\n");
1363 if(node) {
1364 type = _get_node_type(line, (IUnknown*)node);
1365 ok(type == 3, "type=%d\n", type);
1366 IHTMLDOMNode_Release(node);
1367 }
1368
1369 IHTMLDOMChildrenCollection_Release(col);
1370 }
1371
1372 }
1373
1374 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1375 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1376 {
1377 IHTMLElement *elem = _get_elem_iface(line, unk);
1378 BSTR html;
1379 HRESULT hres;
1380
1381 hres = IHTMLElement_get_innerHTML(elem, &html);
1382 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1383 if(inner_html)
1384 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1385 else
1386 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1387
1388 IHTMLElement_Release(elem);
1389 SysFreeString(html);
1390 }
1391
1392 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1393 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1394 {
1395 IHTMLElement *elem = _get_elem_iface(line, unk);
1396 BSTR html;
1397 HRESULT hres;
1398
1399 html = a2bstr(inner_html);
1400 hres = IHTMLElement_put_innerHTML(elem, html);
1401 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1402
1403 IHTMLElement_Release(elem);
1404 SysFreeString(html);
1405 }
1406
1407 #define get_first_child(n) _get_first_child(__LINE__,n)
1408 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1409 {
1410 IHTMLDOMNode *node = _get_node_iface(line, unk);
1411 IHTMLDOMNode *child = NULL;
1412 HRESULT hres;
1413
1414 hres = IHTMLDOMNode_get_firstChild(node, &child);
1415 IHTMLDOMNode_Release(node);
1416 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1417
1418 return child;
1419 }
1420
1421 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1422 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1423 {
1424 IHTMLDOMNode *node = _get_node_iface(line, unk);
1425 VARIANT_BOOL b = 0xdead;
1426 HRESULT hres;
1427
1428 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1429 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1430 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1431
1432 IHTMLDOMNode_Release(node);
1433 }
1434
1435 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1436 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1437 {
1438 IHTMLDOMNode *node = _get_node_iface(line, unk);
1439 IHTMLDOMNode *parent;
1440 HRESULT hres;
1441
1442 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1443 IHTMLDOMNode_Release(node);
1444 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1445
1446 return parent;
1447 }
1448
1449 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1450 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1451 {
1452 IHTMLElement *elem = _get_elem_iface(line, unk);
1453 IHTMLElement *parent;
1454 HRESULT hres;
1455
1456 hres = IHTMLElement_get_parentElement(elem, &parent);
1457 IHTMLElement_Release(elem);
1458 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1459
1460 return parent;
1461 }
1462
1463 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1464 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1465 {
1466 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1467 VARIANT_BOOL disabled = 100;
1468 HRESULT hres;
1469
1470 if (!elem3) return;
1471 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1472 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1473 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1474 IHTMLElement3_Release(elem3);
1475 }
1476
1477 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1478 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1479 {
1480 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1481 HRESULT hres;
1482
1483 if (!elem3) return;
1484 hres = IHTMLElement3_put_disabled(elem3, b);
1485 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1486
1487 IHTMLElement3_Release(elem3);
1488 _test_elem3_get_disabled(line, unk, b);
1489 }
1490
1491 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1492 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1493 {
1494 VARIANT_BOOL disabled = 100;
1495 HRESULT hres;
1496
1497 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1498 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1499 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1500
1501 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1502 }
1503
1504 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1505 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1506 {
1507 HRESULT hres;
1508
1509 hres = IHTMLSelectElement_put_disabled(select, b);
1510 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1511
1512 _test_select_get_disabled(line, select, b);
1513 }
1514
1515 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1516 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1517 {
1518 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1519 IHTMLTextContainer *txtcont;
1520 LONG l = -1, l2 = -1;
1521 HRESULT hres;
1522
1523 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1524 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1525 IHTMLElement2_Release(elem);
1526
1527 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1528 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1529
1530 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1531 IHTMLTextContainer_Release(txtcont);
1532 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1533 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1534
1535 return l;
1536 }
1537
1538 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1539 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1540 {
1541 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1542 IHTMLTextContainer *txtcont;
1543 LONG l = -1, l2 = -1;
1544 HRESULT hres;
1545
1546 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1547 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1548 IHTMLElement2_Release(elem);
1549
1550 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1551 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1552
1553 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1554 IHTMLTextContainer_Release(txtcont);
1555 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1556 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1557
1558 return l;
1559 }
1560
1561 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1562 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1563 {
1564 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1565 IHTMLTextContainer *txtcont;
1566 LONG l = -1, l2 = -1;
1567 HRESULT hres;
1568
1569 hres = IHTMLElement2_get_scrollTop(elem, &l);
1570 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1571 IHTMLElement2_Release(elem);
1572
1573 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1574 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1575
1576 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1577 IHTMLTextContainer_Release(txtcont);
1578 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1579 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1580
1581 return l;
1582 }
1583
1584 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1585 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1586 {
1587 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1588 IHTMLTextContainer *txtcont;
1589 LONG l = -1, l2 = -1;
1590 HRESULT hres;
1591
1592 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1593 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1594
1595 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1596 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1597 IHTMLElement2_Release(elem);
1598
1599 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1600 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1601
1602 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1603 IHTMLTextContainer_Release(txtcont);
1604 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1605 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1606 }
1607
1608 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1609 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1610 {
1611 IHTMLImgElement *img = _get_img_iface(line, unk);
1612 BSTR src;
1613 HRESULT hres;
1614
1615 hres = IHTMLImgElement_get_src(img, &src);
1616 IHTMLImgElement_Release(img);
1617 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1618 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1619 SysFreeString(src);
1620 }
1621
1622 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1623 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1624 {
1625 IHTMLImgElement *img = _get_img_iface(line, unk);
1626 BSTR tmp;
1627 HRESULT hres;
1628
1629 tmp = a2bstr(src);
1630 hres = IHTMLImgElement_put_src(img, tmp);
1631 IHTMLImgElement_Release(img);
1632 SysFreeString(tmp);
1633 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1634
1635 _test_img_src(line, unk, src);
1636 }
1637
1638 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1639 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1640 {
1641 IHTMLImgElement *img = _get_img_iface(line, unk);
1642 BSTR alt;
1643 HRESULT hres;
1644
1645 hres = IHTMLImgElement_get_alt(img, &alt);
1646 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1647 if(exalt)
1648 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1649 else
1650 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1651 SysFreeString(alt);
1652 }
1653
1654 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1655 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1656 {
1657 IHTMLImgElement *img = _get_img_iface(line, unk);
1658 BSTR tmp;
1659 HRESULT hres;
1660
1661 tmp = a2bstr(alt);
1662 hres = IHTMLImgElement_put_alt(img, tmp);
1663 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1664 SysFreeString(tmp);
1665
1666 _test_img_alt(line, unk, alt);
1667 }
1668
1669 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1670 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1671 {
1672 VARIANT_BOOL disabled = 100;
1673 HRESULT hres;
1674
1675 hres = IHTMLInputElement_get_disabled(input, &disabled);
1676 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1677 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1678
1679 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1680 }
1681
1682 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1683 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1684 {
1685 HRESULT hres;
1686
1687 hres = IHTMLInputElement_put_disabled(input, b);
1688 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1689
1690 _test_input_get_disabled(line, input, b);
1691 }
1692
1693 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1694 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1695 {
1696 VARIANT_BOOL checked = 100;
1697 HRESULT hres;
1698
1699 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1700 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1701 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1702 }
1703
1704 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1705 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1706 {
1707 HRESULT hres;
1708
1709 hres = IHTMLInputElement_put_defaultChecked(input, b);
1710 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1711
1712 _test_input_get_defaultchecked(line, input, b);
1713 }
1714
1715 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1716 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1717 {
1718 VARIANT_BOOL checked = 100;
1719 HRESULT hres;
1720
1721 hres = IHTMLInputElement_get_checked(input, &checked);
1722 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1723 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1724 }
1725
1726 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1727 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1728 {
1729 HRESULT hres;
1730
1731 hres = IHTMLInputElement_put_checked(input, b);
1732 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1733
1734 _test_input_get_checked(line, input, b);
1735 }
1736
1737 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1738 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1739 {
1740 IHTMLInputElement *input;
1741 BSTR bstr;
1742 HRESULT hres;
1743
1744 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1745 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1746 if(FAILED(hres))
1747 return;
1748
1749 hres = IHTMLInputElement_get_value(input, &bstr);
1750 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1751 if(exval)
1752 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1753 else
1754 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1755 SysFreeString(bstr);
1756 IHTMLInputElement_Release(input);
1757 }
1758
1759 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1760 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1761 {
1762 IHTMLInputElement *input;
1763 BSTR bstr;
1764 HRESULT hres;
1765
1766 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1767 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1768 if(FAILED(hres))
1769 return;
1770
1771 bstr = a2bstr(val);
1772 hres = IHTMLInputElement_get_value(input, &bstr);
1773 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1774 SysFreeString(bstr);
1775 IHTMLInputElement_Release(input);
1776 }
1777
1778 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
1779 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
1780 {
1781 BSTR src;
1782 HRESULT hres;
1783
1784 hres = IHTMLInputElement_get_src(input, &src);
1785 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1786 if(exsrc)
1787 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1788 else
1789 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
1790 SysFreeString(src);
1791 }
1792
1793 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
1794 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
1795 {
1796 BSTR tmp;
1797 HRESULT hres;
1798
1799 tmp = a2bstr(src);
1800 hres = IHTMLInputElement_put_src(input, tmp);
1801 SysFreeString(tmp);
1802 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1803
1804 _test_input_src(line, input, src);
1805 }
1806
1807 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1808 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
1809 {
1810 IHTMLElement *elem = _get_elem_iface(line, unk);
1811 BSTR class = (void*)0xdeadbeef;
1812 HRESULT hres;
1813
1814 hres = IHTMLElement_get_className(elem, &class);
1815 IHTMLElement_Release(elem);
1816 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
1817 if(exclass)
1818 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
1819 else
1820 ok_(__FILE__,line) (!class, "class != NULL\n");
1821 SysFreeString(class);
1822 }
1823
1824 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1825 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
1826 {
1827 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1828 short index = -3;
1829 HRESULT hres;
1830
1831 hres = IHTMLElement2_get_tabIndex(elem2, &index);
1832 IHTMLElement2_Release(elem2);
1833 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1834 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
1835 }
1836
1837 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1838 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
1839 {
1840 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1841 HRESULT hres;
1842
1843 hres = IHTMLElement2_put_tabIndex(elem2, index);
1844 IHTMLElement2_Release(elem2);
1845 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1846
1847 _test_elem_tabindex(line, unk, index);
1848 }
1849
1850 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1851 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
1852 {
1853 IHTMLElement *elem = _get_elem_iface(line, unk);
1854 BSTR tmp;
1855 HRESULT hres;
1856
1857 tmp = class ? a2bstr(class) : NULL;
1858 hres = IHTMLElement_put_className(elem, tmp);
1859 IHTMLElement_Release(elem);
1860 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
1861 SysFreeString(tmp);
1862
1863 _test_elem_class(line, unk, class);
1864 }
1865
1866 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1867 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
1868 {
1869 IHTMLElement *elem = _get_elem_iface(line, unk);
1870 BSTR id = (void*)0xdeadbeef;
1871 HRESULT hres;
1872
1873 hres = IHTMLElement_get_id(elem, &id);
1874 IHTMLElement_Release(elem);
1875 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
1876
1877 if(exid)
1878 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
1879 else
1880 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
1881
1882 SysFreeString(id);
1883 }
1884
1885 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1886 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
1887 {
1888 IHTMLElement *elem = _get_elem_iface(line, unk);
1889 BSTR tmp = a2bstr(new_id);
1890 HRESULT hres;
1891
1892 hres = IHTMLElement_put_id(elem, tmp);
1893 IHTMLElement_Release(elem);
1894 SysFreeString(tmp);
1895 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
1896
1897 _test_elem_id(line, unk, new_id);
1898 }
1899
1900 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1901 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
1902 {
1903 IHTMLElement *elem = _get_elem_iface(line, unk);
1904 BSTR title;
1905 HRESULT hres;
1906
1907 hres = IHTMLElement_get_title(elem, &title);
1908 IHTMLElement_Release(elem);
1909 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1910 if(extitle)
1911 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
1912 else
1913 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
1914
1915 SysFreeString(title);
1916 }
1917
1918 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1919 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
1920 {
1921 IHTMLElement *elem = _get_elem_iface(line, unk);
1922 BSTR tmp;
1923 HRESULT hres;
1924
1925 tmp = a2bstr(title);
1926 hres = IHTMLElement_put_title(elem, tmp);
1927 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1928
1929 IHTMLElement_Release(elem);
1930 SysFreeString(tmp);
1931 }
1932
1933 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1934 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
1935 {
1936 IHTMLDOMNode *node = _get_node_iface(line, unk);
1937 VARIANT var;
1938 HRESULT hres;
1939
1940 hres = IHTMLDOMNode_get_nodeValue(node, &var);
1941 IHTMLDOMNode_Release(node);
1942 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1943
1944 if(exval) {
1945 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
1946 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
1947 }else {
1948 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
1949 }
1950
1951 VariantClear(&var);
1952 }
1953
1954 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
1955 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
1956 {
1957 IHTMLDOMNode *node = _get_node_iface(line, unk);
1958 VARIANT var;
1959 HRESULT hres;
1960
1961 V_VT(&var) = VT_BSTR;
1962 V_BSTR(&var) = a2bstr(val);
1963
1964 hres = IHTMLDOMNode_put_nodeValue(node, var);
1965 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1966 IHTMLDOMNode_Release(node);
1967 VariantClear(&var);
1968 }
1969
1970 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
1971 static void _test_elem_client_size(unsigned line, IUnknown *unk)
1972 {
1973 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1974 LONG l;
1975 HRESULT hres;
1976
1977 hres = IHTMLElement2_get_clientWidth(elem, &l);
1978 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
1979 hres = IHTMLElement2_get_clientHeight(elem, &l);
1980 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
1981
1982 IHTMLElement2_Release(elem);
1983 }
1984
1985 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
1986 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
1987 {
1988 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1989 LONG l;
1990 HRESULT hres;
1991
1992 hres = IHTMLElement2_get_clientLeft(elem, &l);
1993 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
1994 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
1995
1996 hres = IHTMLElement2_get_clientTop(elem, &l);
1997 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
1998 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
1999
2000 IHTMLElement2_Release(elem);
2001 }
2002
2003 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2004 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2005 {
2006 IHTMLElement *elem = NULL;
2007 BSTR tmp;
2008 HRESULT hres;
2009
2010 tmp = a2bstr(tag);
2011 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2012 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2013 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2014
2015 return elem;
2016 }
2017
2018 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2019 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2020 {
2021 IHTMLDocument3 *doc3;
2022 IHTMLDOMNode *node = NULL;
2023 BSTR tmp;
2024 HRESULT hres;
2025
2026 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2027 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2028
2029 tmp = a2bstr(text);
2030 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2031 IHTMLDocument3_Release(doc3);
2032 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2033 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2034
2035 return node;
2036 }
2037
2038 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2039 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2040 {
2041 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2042 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2043 IHTMLDOMNode *new_child = NULL;
2044 HRESULT hres;
2045
2046 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2047 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2048 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2049 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2050
2051 IHTMLDOMNode_Release(node);
2052 IHTMLDOMNode_Release(child);
2053
2054 return new_child;
2055 }
2056
2057 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2058 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2059 {
2060 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2061 IHTMLDOMNode *new_child = NULL;
2062 HRESULT hres;
2063
2064 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2065 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2066 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2067 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2068
2069 IHTMLDOMNode_Release(node);
2070
2071 return new_child;
2072 }
2073
2074 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2075 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2076 {
2077 IHTMLDOMNode *node = _get_node_iface(line, unk);
2078 IHTMLDOMNode *new_node = NULL;
2079 HRESULT hres;
2080
2081 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2082 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2083 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2084 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2085
2086 IHTMLDOMNode_Release(node);
2087 IHTMLDOMNode_Release(new_node);
2088 }
2089
2090 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2091 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2092 {
2093 BSTR title = NULL;
2094 HRESULT hres;
2095
2096 hres = IHTMLDocument2_get_title(doc, &title);
2097 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2098 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2099 SysFreeString(title);
2100 }
2101
2102 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2103 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2104 {
2105 BSTR tmp;
2106 HRESULT hres;
2107
2108 tmp = a2bstr(title);
2109 hres = IHTMLDocument2_put_title(doc, tmp);
2110 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2111 SysFreeString(tmp);
2112 }
2113
2114 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2115 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2116 {
2117 HRESULT hres;
2118 DISPID dispid;
2119
2120 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2121 LOCALE_USER_DEFAULT, &dispid);
2122 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2123 if(hres == S_OK)
2124 {
2125 DISPPARAMS params = {NULL,NULL,0,0};
2126 DISPID dispidNamed = DISPID_PROPERTYPUT;
2127 VARIANT ret;
2128 VARIANT vDefault;
2129 VARIANTARG arg;
2130
2131 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2132 DISPATCH_PROPERTYGET, &params, &vDefault, NULL, NULL);
2133 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2134
2135 params.cArgs = 1;
2136 params.cNamedArgs = 1;
2137 params.rgdispidNamedArgs = &dispidNamed;
2138 V_VT(&arg) = VT_BSTR;
2139 V_BSTR(&arg) = a2bstr("none");
2140 params.rgvarg = &arg;
2141 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2142 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2143 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2144 VariantClear(&arg);
2145
2146 V_VT(&arg) = VT_BSTR;
2147 V_BSTR(&arg) = a2bstr("dotted");
2148 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2149 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2150 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2151 VariantClear(&arg);
2152
2153 V_VT(&arg) = VT_BSTR;
2154 V_BSTR(&arg) = a2bstr("dashed");
2155 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2156 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2157 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2158 VariantClear(&arg);
2159
2160 V_VT(&arg) = VT_BSTR;
2161 V_BSTR(&arg) = a2bstr("solid");
2162 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2163 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2164 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2165 VariantClear(&arg);
2166
2167 V_VT(&arg) = VT_BSTR;
2168 V_BSTR(&arg) = a2bstr("double");
2169 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2170 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2171 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2172 VariantClear(&arg);
2173
2174 V_VT(&arg) = VT_BSTR;
2175 V_BSTR(&arg) = a2bstr("groove");
2176 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2177 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2178 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2179 VariantClear(&arg);
2180
2181 V_VT(&arg) = VT_BSTR;
2182 V_BSTR(&arg) = a2bstr("ridge");
2183 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2184 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2185 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2186 VariantClear(&arg);
2187
2188 V_VT(&arg) = VT_BSTR;
2189 V_BSTR(&arg) = a2bstr("inset");
2190 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2191 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2192 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2193 VariantClear(&arg);
2194
2195 V_VT(&arg) = VT_BSTR;
2196 V_BSTR(&arg) = a2bstr("outset");
2197 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2198 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2199 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2200 VariantClear(&arg);
2201
2202 V_VT(&arg) = VT_BSTR;
2203 V_BSTR(&arg) = a2bstr("invalid");
2204 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2205 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2206 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2207 VariantClear(&arg);
2208
2209 params.rgvarg = &vDefault;
2210 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2211 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2212 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2213 }
2214 }
2215
2216 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2217 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2218 {
2219 BSTR text = (void*)0xdeadbeef;
2220 HRESULT hres;
2221
2222 hres = IHTMLStyle_get_cssText(style, &text);
2223 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2224 if(extext)
2225 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2226 else
2227 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2228
2229 SysFreeString(text);
2230 }
2231
2232 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2233 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2234 {
2235 BSTR tmp;
2236 HRESULT hres;
2237
2238 tmp = a2bstr(text);
2239 hres = IHTMLStyle_put_cssText(style, tmp);
2240 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2241 SysFreeString(tmp);
2242 }
2243
2244 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2245 const elem_type_t *elem_types, LONG len)
2246 {
2247 IDispatch *disp;
2248 VARIANT name, index;
2249 DWORD i;
2250 HRESULT hres;
2251
2252 V_VT(&index) = VT_EMPTY;
2253 V_VT(&name) = VT_BSTR;
2254 V_BSTR(&name) = a2bstr(n);
2255
2256 hres = IHTMLElementCollection_item(col, name, index, &disp);
2257 ok(hres == S_OK, "item failed: %08x\n", hres);
2258
2259 test_elem_collection((IUnknown*)disp, elem_types, len);
2260 IDispatch_Release(disp);
2261 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2262 if(hres != S_OK)
2263 goto cleanup;
2264
2265 V_VT(&index) = VT_I4;
2266
2267 for(i=0; i<len; i++) {
2268 V_I4(&index) = i;
2269 disp = (void*)0xdeadbeef;
2270 hres = IHTMLElementCollection_item(col, name, index, &disp);
2271 ok(hres == S_OK, "item failed: %08x\n", hres);
2272 ok(disp != NULL, "disp == NULL\n");
2273 if(FAILED(hres) || !disp)
2274 continue;
2275
2276 test_elem_type((IUnknown*)disp, elem_types[i]);
2277
2278 IDispatch_Release(disp);
2279 }
2280
2281 V_I4(&index) = len;
2282 disp = (void*)0xdeadbeef;
2283 hres = IHTMLElementCollection_item(col, name, index, &disp);
2284 ok(hres == S_OK, "item failed: %08x\n", hres);
2285 ok(disp == NULL, "disp != NULL\n");
2286
2287 V_I4(&index) = -1;
2288 disp = (void*)0xdeadbeef;
2289 hres = IHTMLElementCollection_item(col, name, index, &disp);
2290 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2291 ok(disp == NULL, "disp != NULL\n");
2292
2293 cleanup:
2294 SysFreeString(V_BSTR(&name));
2295 }
2296
2297 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2298 {
2299 IHTMLElementCollection *col;
2300 IHTMLElement *elem;
2301 IDispatch *disp = (void*)0xdeadbeef;
2302 VARIANT name, index;
2303 HRESULT hres;
2304
2305 hres = IHTMLDocument2_get_all(doc, &col);
2306 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2307 ok(col != NULL, "col == NULL\n");
2308 if(FAILED(hres) || !col)
2309 return NULL;
2310
2311 V_VT(&index) = VT_EMPTY;
2312 V_VT(&name) = VT_BSTR;
2313 V_BSTR(&name) = a2bstr(id);
2314
2315 hres = IHTMLElementCollection_item(col, name, index, &disp);
2316 IHTMLElementCollection_Release(col);
2317 SysFreeString(V_BSTR(&name));
2318 ok(hres == S_OK, "item failed: %08x\n", hres);
2319 if(!expect_success) {
2320 ok(disp == NULL, "disp != NULL\n");
2321 return NULL;
2322 }
2323
2324 ok(disp != NULL, "disp == NULL\n");
2325 if(!disp)
2326 return NULL;
2327
2328 elem = get_elem_iface((IUnknown*)disp);
2329 IDispatch_Release(disp);
2330
2331 return elem;
2332 }
2333
2334 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2335 {
2336 IHTMLDocument3 *doc3;
2337 IHTMLElement *elem;
2338 BSTR tmp;
2339 HRESULT hres;
2340
2341 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2342 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2343
2344 tmp = a2bstr(id);
2345 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2346 SysFreeString(tmp);
2347 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2348
2349 IHTMLDocument3_Release(doc3);
2350
2351 return elem;
2352 }
2353
2354 static void test_select_elem(IHTMLSelectElement *select)
2355 {
2356 test_select_type(select, "select-one");
2357 test_select_length(select, 2);
2358 test_select_selidx(select, 0);
2359 test_select_put_selidx(select, 1);
2360
2361 test_select_set_value(select, "val1");
2362 test_select_value(select, "val1");
2363
2364 test_select_get_disabled(select, VARIANT_FALSE);
2365 test_select_set_disabled(select, VARIANT_TRUE);
2366 test_select_set_disabled(select, VARIANT_FALSE);
2367 }
2368
2369 static void test_create_option_elem(IHTMLDocument2 *doc)
2370 {
2371 IHTMLOptionElement *option;
2372
2373 option = create_option_elem(doc, "test text", "test value");
2374
2375 test_option_put_text(option, "new text");
2376 test_option_put_value(option, "new value");
2377
2378 IHTMLOptionElement_Release(option);
2379 }
2380
2381 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2382 {
2383 IHTMLBodyElement *body;
2384 IHTMLTxtRange *range;
2385 IHTMLElement *elem;
2386 HRESULT hres;
2387
2388 hres = IHTMLDocument2_get_body(doc, &elem);
2389 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2390
2391 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2392 IHTMLElement_Release(elem);
2393
2394 hres = IHTMLBodyElement_createTextRange(body, &range);
2395 IHTMLBodyElement_Release(body);
2396 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2397
2398 return range;
2399 }
2400
2401 static void test_txtrange(IHTMLDocument2 *doc)
2402 {
2403 IHTMLTxtRange *body_range, *range, *range2;
2404 IHTMLSelectionObject *selection;
2405 IDispatch *disp_range;
2406 HRESULT hres;
2407
2408 body_range = test_create_body_range(doc);
2409
2410 test_range_text(body_range, "test abc 123\r\nit's text");
2411
2412 hres = IHTMLTxtRange_duplicate(body_range, &range);
2413 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2414
2415 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2416 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2417 test_range_isequal(range, range2, VARIANT_TRUE);
2418
2419 test_range_text(range, "test abc 123\r\nit's text");
2420 test_range_text(body_range, "test abc 123\r\nit's text");
2421
2422 test_range_collapse(range, TRUE);
2423 test_range_isequal(range, range2, VARIANT_FALSE);
2424 test_range_inrange(range, range2, VARIANT_FALSE);
2425 test_range_inrange(range2, range, VARIANT_TRUE);
2426 IHTMLTxtRange_Release(range2);
2427
2428 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2429 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2430 test_range_move(range, characterW, 2, 2);
2431 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2432
2433 test_range_collapse(range, FALSE);
2434 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2435
2436 test_range_collapse(range, FALSE);
2437 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2438 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2439 test_range_move(range, characterW, 2, 2);
2440 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2441 test_range_moveend(range, characterW, -5, -5);
2442 test_range_text(range, NULL);
2443 test_range_moveend(range, characterW, 3, 3);
2444 test_range_text(range, "c 1");
2445 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2446 test_range_collapse(range, TRUE);
2447 test_range_move(range, characterW, 4, 4);
2448 test_range_moveend(range, characterW, 1, 1);
2449 test_range_text(range, " ");
2450 test_range_move(range, wordW, 1, 1);
2451 test_range_moveend(range, characterW, 2, 2);
2452 test_range_text(range, "ab");
2453
2454 IHTMLTxtRange_Release(range);
2455
2456 hres = IHTMLTxtRange_duplicate(body_range, &range);
2457 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2458
2459 test_range_text(range, "test abc 123\r\nit's text");
2460 test_range_move(range, characterW, 3, 3);
2461 test_range_moveend(range, characterW, 1, 1);
2462 test_range_text(range, "t");
2463 test_range_moveend(range, characterW, 3, 3);
2464 test_range_text(range, "t ab");
2465 test_range_moveend(range, characterW, -2, -2);
2466 test_range_text(range, "t ");
2467 test_range_move(range, characterW, 6, 6);
2468 test_range_moveend(range, characterW, 3, 3);
2469 test_range_text(range, "123");
2470 test_range_moveend(range, characterW, 2, 2);
2471 test_range_text(range, "123\r\ni");
2472
2473 IHTMLTxtRange_Release(range);
2474
2475 hres = IHTMLTxtRange_duplicate(body_range, &range);
2476 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2477
2478 test_range_move(range, wordW, 1, 1);
2479 test_range_moveend(range, characterW, 2, 2);
2480 test_range_text(range, "ab");
2481
2482 test_range_move(range, characterW, -2, -2);
2483 test_range_moveend(range, characterW, 2, 2);
2484 test_range_text(range, "t ");
2485
2486 test_range_move(range, wordW, 3, 3);
2487 test_range_move(range, wordW, -2, -2);
2488 test_range_moveend(range, characterW, 2, 2);
2489 test_range_text(range, "ab");
2490
2491 test_range_move(range, characterW, -6, -5);
2492 test_range_moveend(range, characterW, -1, 0);
2493 test_range_moveend(range, characterW, -6, 0);
2494 test_range_move(range, characterW, 2, 2);
2495 test_range_moveend(range, characterW, 2, 2);
2496 test_range_text(range, "st");
2497 test_range_moveend(range, characterW, -6, -4);
2498 test_range_moveend(range, characterW, 2, 2);
2499
2500 IHTMLTxtRange_Release(range);
2501
2502 hres = IHTMLTxtRange_duplicate(body_range, &range);
2503 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2504
2505 test_range_move(range, wordW, 2, 2);
2506 test_range_moveend(range, characterW, 2, 2);
2507 test_range_text(range, "12");
2508
2509 test_range_move(range, characterW, 15, 14);
2510 test_range_move(range, characterW, -2, -2);
2511 test_range_moveend(range, characterW, 3, 2);
2512 test_range_text(range, "t");
2513 test_range_moveend(range, characterW, -1, -1);
2514 test_range_text(range, "t");
2515 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2516 test_range_move(range, characterW, -2, -2);
2517 test_range_moveend(range, characterW, 2, 2);
2518 test_range_text(range, "s ");
2519 test_range_move(range, characterW, 100, 7);
2520 test_range_move(range, wordW, 1, 0);
2521 test_range_move(range, characterW, -2, -2);
2522 test_range_moveend(range, characterW, 3, 2);
2523 test_range_text(range, "t");
2524
2525 IHTMLTxtRange_Release(range);
2526
2527 hres = IHTMLTxtRange_duplicate(body_range, &range);
2528 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2529
2530 test_range_collapse(range, TRUE);
2531 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2532 test_range_put_text(range, "word");
2533 test_range_text(body_range, "wordabc 123\r\nit's text");
2534 test_range_text(range, NULL);
2535 test_range_moveend(range, characterW, 3, 3);
2536 test_range_text(range, "abc");
2537 test_range_movestart(range, characterW, -2, -2);
2538 test_range_text(range, "rdabc");
2539 test_range_movestart(range, characterW, 3, 3);
2540 test_range_text(range, "bc");
2541 test_range_movestart(range, characterW, 4, 4);
2542 test_range_text(range, NULL);
2543 test_range_movestart(range, characterW, -3, -3);
2544 test_range_text(range, "c 1");
2545 test_range_movestart(range, characterW, -7, -6);
2546 test_range_text(range, "wordabc 1");
2547 test_range_movestart(range, characterW, 100, 22);
2548 test_range_text(range, NULL);
2549
2550 IHTMLTxtRange_Release(range);
2551 IHTMLTxtRange_Release(body_range);
2552
2553 hres = IHTMLDocument2_get_selection(doc, &selection);
2554 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2555
2556 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2557 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2558 IHTMLSelectionObject_Release(selection);
2559
2560 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2561 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2562 IDispatch_Release(disp_range);
2563
2564 test_range_text(range, NULL);
2565 test_range_moveend(range, characterW, 3, 3);
2566 test_range_text(range, "wor");
2567 test_range_parent(range, ET_BODY);
2568 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2569 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2570 test_range_move(range, characterW, 3, 3);
2571 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2572 test_range_moveend(range, characterW, -4, -4);
2573 test_range_put_text(range, "abc def ");
2574 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2575 test_range_move(range, wordW, 1, 1);
2576 test_range_movestart(range, characterW, -1, -1);
2577 test_range_text(range, " ");
2578 test_range_move(range, wordW, 1, 1);
2579 test_range_moveend(range, characterW, 3, 3);
2580 test_range_text(range, "def");
2581 test_range_put_text(range, "xyz");
2582 test_range_moveend(range, characterW, 1, 1);
2583 test_range_move(range, wordW, 1, 1);
2584 test_range_moveend(range, characterW, 2, 2);
2585 test_range_text(range, "ab");
2586
2587 IHTMLTxtRange_Release(range);
2588 }
2589
2590 static void test_txtrange2(IHTMLDocument2 *doc)
2591 {
2592 IHTMLTxtRange *range;
2593
2594 range = test_create_body_range(doc);
2595
2596 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2597 test_range_move(range, characterW, 5, 5);
2598 test_range_moveend(range, characterW, 1, 1);
2599 test_range_text(range, "2");
2600 test_range_move(range, characterW, -3, -3);
2601 test_range_moveend(range, characterW, 3, 3);
2602 test_range_text(range, "c\r\n\r\n1");
2603 test_range_collapse(range, VARIANT_FALSE);
2604 test_range_moveend(range, characterW, 4, 4);
2605 test_range_text(range, "23");
2606 test_range_moveend(range, characterW, 1, 1);
2607 test_range_text(range, "23\r\n\r\n\r\nd");
2608 test_range_moveend(range, characterW, -1, -1);
2609 test_range_text(range, "23");
2610 test_range_moveend(range, characterW, -1, -1);
2611 test_range_text(range, "23");
2612 test_range_moveend(range, characterW, -2, -2);
2613 test_range_text(range, "2");
2614
2615 IHTMLTxtRange_Release(range);
2616 }
2617
2618 static void test_compatmode(IHTMLDocument2 *doc)
2619 {
2620 IHTMLDocument5 *doc5;
2621 BSTR mode;
2622 HRESULT hres;
2623
2624 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2625 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2626 if(FAILED(hres))
2627 return;
2628
2629 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2630 IHTMLDocument5_Release(doc5);
2631 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2632 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2633 SysFreeString(mode);
2634 }
2635
2636 static void test_location(IHTMLDocument2 *doc)
2637 {
2638 IHTMLLocation *location, *location2;
2639 IHTMLWindow2 *window;
2640 BSTR str;
2641 ULONG ref;
2642 HRESULT hres;
2643
2644 hres = IHTMLDocument2_get_location(doc, &location);
2645 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2646
2647 hres = IHTMLDocument2_get_location(doc, &location2);
2648 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2649
2650 ok(location == location2, "location != location2\n");
2651 IHTMLLocation_Release(location2);
2652
2653 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2654 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2655
2656 hres = IHTMLWindow2_get_location(window, &location2);
2657 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2658 ok(location == location2, "location != location2\n");
2659 IHTMLLocation_Release(location2);
2660
2661 test_ifaces((IUnknown*)location, location_iids);
2662 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2663
2664 hres = IHTMLLocation_get_pathname(location, &str);
2665 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2666 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2667
2668 hres = IHTMLLocation_get_href(location, NULL);
2669 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2670
2671 hres = IHTMLLocation_get_href(location, &str);
2672 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2673 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2674
2675 ref = IHTMLLocation_Release(location);
2676 ok(!ref, "location chould be destroyed here\n");
2677 }
2678
2679 static void test_navigator(IHTMLDocument2 *doc)
2680 {
2681 IHTMLWindow2 *window;
2682 IOmNavigator *navigator, *navigator2;
2683 char buf[512];
2684 DWORD size;
2685 ULONG ref;
2686 BSTR bstr;
2687 HRESULT hres;
2688
2689 static const WCHAR v40[] = {'4','.','0'};
2690
2691 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2692 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2693
2694 hres = IHTMLWindow2_get_navigator(window, &navigator);
2695 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2696 ok(navigator != NULL, "navigator == NULL\n");
2697 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2698
2699 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2700 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2701 ok(navigator != navigator2, "navigator2 != navihgator\n");
2702
2703 IHTMLWindow2_Release(window);
2704 IOmNavigator_Release(navigator2);
2705
2706 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2707 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2708 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2709 SysFreeString(bstr);
2710
2711 bstr = NULL;
2712 hres = IOmNavigator_get_appName(navigator, &bstr);
2713 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
2714 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2715 SysFreeString(bstr);
2716
2717 bstr = NULL;
2718 hres = IOmNavigator_get_platform(navigator, &bstr);
2719 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2720 #ifdef _WIN64
2721 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2722 #else
2723 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2724 #endif
2725 SysFreeString(bstr);
2726
2727 bstr = NULL;
2728 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2729 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2730 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
2731 SysFreeString(bstr);
2732
2733 hres = IOmNavigator_toString(navigator, NULL);
2734 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
2735
2736 bstr = NULL;
2737 hres = IOmNavigator_toString(navigator, &bstr);
2738 ok(hres == S_OK, "toString failed: %08x\n", hres);
2739 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
2740 SysFreeString(bstr);
2741
2742 size = sizeof(buf);
2743 hres = ObtainUserAgentString(0, buf, &size);
2744 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
2745
2746 bstr = NULL;
2747 hres = IOmNavigator_get_userAgent(navigator, &bstr);
2748 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
2749 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
2750 SysFreeString(bstr);
2751
2752 ref = IOmNavigator_Release(navigator);
2753 ok(!ref, "navigator should be destroyed here\n");
2754 }
2755
2756 static void test_current_style(IHTMLCurrentStyle *current_style)
2757 {
2758 BSTR str;
2759 HRESULT hres;
2760 VARIANT v;
2761
2762 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
2763 test_ifaces((IUnknown*)current_style, cstyle_iids);
2764
2765 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2766 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2767 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
2768 SysFreeString(str);
2769
2770 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2771 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2772 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
2773 SysFreeString(str);
2774
2775 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
2776 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2777 SysFreeString(str);
2778
2779 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
2780 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
2781 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
2782 SysFreeString(str);
2783
2784 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
2785 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
2786 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
2787 SysFreeString(str);
2788
2789 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
2790 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2791 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
2792 SysFreeString(str);
2793
2794 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
2795 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
2796 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
2797 SysFreeString(str);
2798
2799 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
2800 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
2801 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
2802 SysFreeString(str);
2803
2804 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
2805 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
2806 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
2807 SysFreeString(str);
2808
2809 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
2810 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
2811 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
2812 SysFreeString(str);
2813
2814 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
2815 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
2816 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
2817 SysFreeString(str);
2818
2819 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
2820 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2821 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
2822 SysFreeString(str);
2823
2824 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
2825 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
2826 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
2827 SysFreeString(str);
2828
2829 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
2830 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
2831 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
2832 SysFreeString(str);
2833
2834 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
2835 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
2836 SysFreeString(str);
2837
2838 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
2839 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
2840 SysFreeString(str);
2841
2842 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
2843 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
2844 SysFreeString(str);
2845
2846 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
2847 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
2848 SysFreeString(str);
2849
2850 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
2851 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
2852 SysFreeString(str);
2853
2854 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
2855 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
2856 SysFreeString(str);
2857
2858 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
2859 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2860 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2861 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
2862 VariantClear(&v);
2863
2864 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
2865 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
2866 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2867 VariantClear(&v);
2868
2869 hres = IHTMLCurrentStyle_get_left(current_style, &v);
2870 ok(hres == S_OK, "get_left failed: %08x\n", hres);
2871 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2872 VariantClear(&v);
2873
2874 hres = IHTMLCurrentStyle_get_top(current_style, &v);
2875 ok(hres == S_OK, "get_top failed: %08x\n", hres);
2876 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2877 VariantClear(&v);
2878
2879 hres = IHTMLCurrentStyle_get_width(current_style, &v);
2880 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2881 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2882 VariantClear(&v);
2883
2884 hres = IHTMLCurrentStyle_get_height(current_style, &v);
2885 ok(hres == S_OK, "get_height failed: %08x\n", hres);
2886 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2887 VariantClear(&v);
2888
2889 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
2890 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
2891 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2892 VariantClear(&v);
2893
2894 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
2895 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
2896 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2897 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
2898 VariantClear(&v);
2899
2900 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
2901 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
2902 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2903 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
2904 VariantClear(&v);
2905
2906 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
2907 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
2908 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2909 VariantClear(&v);
2910
2911 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
2912 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
2913 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2914 VariantClear(&v);
2915
2916 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
2917 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
2918 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2919 VariantClear(&v);
2920
2921 V_BSTR(&v) = NULL;
2922 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
2923 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
2924 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2925 VariantClear(&v);
2926
2927 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
2928 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
2929 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2930 VariantClear(&v);
2931
2932 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
2933 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
2934 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2935 VariantClear(&v);
2936
2937 hres = IHTMLCurrentStyle_get_color(current_style, &v);
2938 ok(hres == S_OK, "get_color failed: %08x\n", hres);
2939 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2940 VariantClear(&v);
2941
2942 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
2943 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
2944 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2945 VariantClear(&v);
2946
2947 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
2948 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
2949 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2950 VariantClear(&v);
2951
2952 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
2953 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
2954 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2955 VariantClear(&v);
2956
2957 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
2958 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
2959 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2960 VariantClear(&v);
2961
2962 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
2963 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
2964 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2965 VariantClear(&v);
2966
2967 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
2968 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
2969 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2970 VariantClear(&v);
2971
2972 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
2973 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
2974 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2975 VariantClear(&v);
2976
2977 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
2978 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
2979 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2980 VariantClear(&v);
2981
2982 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
2983 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
2984 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2985 VariantClear(&v);
2986
2987 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
2988 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
2989 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2990 VariantClear(&v);
2991
2992 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
2993 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
2994 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2995 VariantClear(&v);
2996
2997 hres = IHTMLCurrentStyle_get_right(current_style, &v);
2998 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
2999 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3000 VariantClear(&v);
3001
3002 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3003 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3004 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3005 VariantClear(&v);
3006
3007 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3008 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3009 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3010 VariantClear(&v);
3011
3012 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3013 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3014 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3015 VariantClear(&v);
3016 }
3017
3018 static void test_style2(IHTMLStyle2 *style2)
3019 {
3020 BSTR str;
3021 HRESULT hres;
3022
3023 str = (void*)0xdeadbeef;
3024 hres = IHTMLStyle2_get_position(style2, &str);
3025 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3026 ok(!str, "str != NULL\n");
3027
3028 str = a2bstr("absolute");
3029 hres = IHTMLStyle2_put_position(style2, str);
3030 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3031 SysFreeString(str);
3032
3033 str = NULL;
3034 hres = IHTMLStyle2_get_position(style2, &str);
3035 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3036 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3037 SysFreeString(str);
3038 }
3039
3040 static void test_style3(IHTMLStyle3 *style3)
3041 {
3042 BSTR str;
3043 HRESULT hres;
3044
3045 str = (void*)0xdeadbeef;
3046 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3047 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3048 ok(!str, "str != NULL\n");
3049
3050 str = a2bstr("break-word");
3051 hres = IHTMLStyle3_put_wordWrap(style3, str);
3052 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3053 SysFreeString(str);
3054
3055 str = NULL;
3056 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3057 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3058 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3059 SysFreeString(str);
3060 }
3061
3062 static void test_style4(IHTMLStyle4 *style4)
3063 {
3064 HRESULT hres;
3065 VARIANT v;
3066 VARIANT vdefault;
3067
3068 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3069 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3070
3071 V_VT(&v) = VT_BSTR;
3072 V_BSTR(&v) = a2bstr("10px");
3073 hres = IHTMLStyle4_put_minHeight(style4, v);
3074 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3075 VariantClear(&v);
3076
3077 hres = IHTMLStyle4_get_minHeight(style4, &v);
3078 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3079 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3080 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3081
3082 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3083 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3084 VariantClear(&vdefault);
3085 }
3086
3087 static void test_default_style(IHTMLStyle *style)
3088 {
3089 IHTMLStyle2 *style2;
3090 IHTMLStyle3 *style3;
3091 IHTMLStyle4 *style4;
3092 VARIANT_BOOL b;
3093 VARIANT v;
3094 BSTR str;
3095 HRESULT hres;
3096 float f;
3097 BSTR sOverflowDefault;
3098 BSTR sDefault;
3099 VARIANT vDefault;
3100
3101 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3102 test_ifaces((IUnknown*)style, style_iids);
3103
3104 test_style_csstext(style, NULL);
3105
3106 hres = IHTMLStyle_get_position(style, &str);
3107 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3108 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3109
3110 V_VT(&v) = VT_NULL;
3111 hres = IHTMLStyle_get_marginRight(style, &v);
3112 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3113 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3114 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3115
3116 V_VT(&v) = VT_NULL;
3117 hres = IHTMLStyle_get_marginLeft(style, &v);
3118 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3119 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3120 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3121
3122 str = (void*)0xdeadbeef;
3123 hres = IHTMLStyle_get_fontFamily(style, &str);
3124 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3125 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3126
3127 str = (void*)0xdeadbeef;
3128 hres = IHTMLStyle_get_fontWeight(style, &str);
3129 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3130 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3131
3132 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3133 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3134
3135 str = a2bstr("test");
3136 hres = IHTMLStyle_put_fontWeight(style, str);
3137 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3138 SysFreeString(str);
3139
3140 str = a2bstr("bold");
3141 hres = IHTMLStyle_put_fontWeight(style, str);
3142 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3143 SysFreeString(str);
3144
3145 str = a2bstr("bolder");
3146 hres = IHTMLStyle_put_fontWeight(style, str);
3147 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3148 SysFreeString(str);
3149
3150 str = a2bstr("lighter");
3151 hres = IHTMLStyle_put_fontWeight(style, str);
3152 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3153 SysFreeString(str);
3154
3155 str = a2bstr("100");
3156 hres = IHTMLStyle_put_fontWeight(style, str);
3157 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3158 SysFreeString(str);
3159
3160 str = a2bstr("200");
3161 hres = IHTMLStyle_put_fontWeight(style, str);
3162 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3163 SysFreeString(str);
3164
3165 str = a2bstr("300");
3166 hres = IHTMLStyle_put_fontWeight(style, str);
3167 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3168 SysFreeString(str);
3169
3170 str = a2bstr("400");
3171 hres = IHTMLStyle_put_fontWeight(style, str);
3172 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3173 SysFreeString(str);
3174
3175 str = a2bstr("500");
3176 hres = IHTMLStyle_put_fontWeight(style, str);
3177 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3178 SysFreeString(str);
3179
3180 str = a2bstr("600");
3181 hres = IHTMLStyle_put_fontWeight(style, str);
3182 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3183 SysFreeString(str);
3184
3185 str = a2bstr("700");
3186 hres = IHTMLStyle_put_fontWeight(style, str);
3187 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3188 SysFreeString(str);
3189
3190 str = a2bstr("800");
3191 hres = IHTMLStyle_put_fontWeight(style, str);
3192 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3193 SysFreeString(str);
3194
3195 str = a2bstr("900");
3196 hres = IHTMLStyle_put_fontWeight(style, str);
3197 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3198 SysFreeString(str);
3199
3200 hres = IHTMLStyle_get_fontWeight(style, &str);
3201 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3202 ok(!strcmp_wa(str, "900"), "str != style900\n");
3203 SysFreeString(str);
3204
3205 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3206 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3207 SysFreeString(sDefault);
3208
3209 /* font Variant */
3210 hres = IHTMLStyle_get_fontVariant(style, NULL);
3211 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3212
3213 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3214 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3215
3216 str = a2bstr("test");
3217 hres = IHTMLStyle_put_fontVariant(style, str);
3218 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3219 SysFreeString(str);
3220
3221 str = a2bstr("small-caps");
3222 hres = IHTMLStyle_put_fontVariant(style, str);
3223 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3224 SysFreeString(str);
3225
3226 str = a2bstr("normal");
3227 hres = IHTMLStyle_put_fontVariant(style, str);
3228 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3229 SysFreeString(str);
3230
3231 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3232 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3233 SysFreeString(sDefault);
3234
3235 str = (void*)0xdeadbeef;
3236 hres = IHTMLStyle_get_display(style, &str);
3237 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3238 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3239
3240 str = (void*)0xdeadbeef;
3241 hres = IHTMLStyle_get_visibility(style, &str);
3242 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3243 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3244
3245 V_VT(&v) = VT_NULL;
3246 hres = IHTMLStyle_get_fontSize(style, &v);
3247 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3248 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3249 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3250
3251 V_VT(&v) = VT_NULL;
3252 hres = IHTMLStyle_get_color(style, &v);
3253 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3254 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3255 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3256
3257 b = 0xfefe;
3258 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3259 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3260 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3261
3262 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3263 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3264 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3265
3266 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3267 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3268 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3269
3270 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3271 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3272
3273 b = 0xfefe;
3274 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3275 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3276 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3277
3278 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3279 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3280 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3281
3282 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3283 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3284 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3285
3286 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3287 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3288
3289 b = 0xfefe;
3290 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3291 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3292 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3293
3294 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3295 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3296 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3297
3298 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3299 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3300 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3301
3302 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3303 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3304
3305 b = 0xfefe;
3306 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3307 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3308 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3309
3310 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3311 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3312 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3313
3314 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3315 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3316 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3317
3318 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3319 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3320
3321 b = 0xfefe;
3322 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3323 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3324 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3325
3326 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3327 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3328 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3329
3330 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3331 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3332 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3333
3334 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3335 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3336
3337 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3338 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3339
3340 str = a2bstr("invalid");
3341 hres = IHTMLStyle_put_textDecoration(style, str);
3342 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3343 SysFreeString(str);
3344
3345 str = a2bstr("none");
3346 hres = IHTMLStyle_put_textDecoration(style, str);
3347 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3348 SysFreeString(str);
3349
3350 str = a2bstr("underline");
3351 hres = IHTMLStyle_put_textDecoration(style, str);
3352 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3353 SysFreeString(str);
3354
3355 str = a2bstr("overline");
3356 hres = IHTMLStyle_put_textDecoration(style, str);
3357 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3358 SysFreeString(str);
3359
3360 str = a2bstr("line-through");
3361 hres = IHTMLStyle_put_textDecoration(style, str);
3362 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3363 SysFreeString(str);
3364
3365 str = a2bstr("blink");
3366 hres = IHTMLStyle_put_textDecoration(style, str);
3367 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3368 SysFreeString(str);
3369
3370 hres = IHTMLStyle_get_textDecoration(style, &str);
3371 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3372 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3373 SysFreeString(str);
3374
3375 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3376 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3377 SysFreeString(sDefault);
3378
3379 hres = IHTMLStyle_get_posWidth(style, NULL);
3380 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3381
3382 hres = IHTMLStyle_get_posWidth(style, &f);
3383 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3384 ok(f == 0.0f, "f = %f\n", f);
3385
3386 V_VT(&v) = VT_EMPTY;
3387 hres = IHTMLStyle_get_width(style, &v);
3388 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3389 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3390 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3391
3392 hres = IHTMLStyle_put_posWidth(style, 2.2);
3393 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3394
3395 hres = IHTMLStyle_get_posWidth(style, &f);
3396 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3397 ok(f == 2.0f ||
3398 f == 2.2f, /* IE8 */
3399 "f = %f\n", f);
3400
3401 V_VT(&v) = VT_BSTR;
3402 V_BSTR(&v) = a2bstr("auto");
3403 hres = IHTMLStyle_put_width(style, v);
3404 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3405 VariantClear(&v);
3406
3407 V_VT(&v) = VT_EMPTY;
3408 hres = IHTMLStyle_get_width(style, &v);
3409 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3410 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3411 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3412 VariantClear(&v);
3413
3414 /* margin tests */
3415 str = (void*)0xdeadbeef;
3416 hres = IHTMLStyle_get_margin(style, &str);
3417 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3418 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3419
3420 str = a2bstr("1");
3421 hres = IHTMLStyle_put_margin(style, str);
3422 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3423 SysFreeString(str);
3424
3425 hres = IHTMLStyle_get_margin(style, &str);
3426 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3427 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3428
3429 hres = IHTMLStyle_put_margin(style, NULL);
3430 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3431
3432 str = NULL;
3433 hres = IHTMLStyle_get_border(style, &str);
3434 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3435 ok(!str || !*str, "str is not empty\n");
3436 SysFreeString(str);
3437
3438 str = a2bstr("1px");
3439 hres = IHTMLStyle_put_border(style, str);
3440 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3441 SysFreeString(str);
3442
3443 V_VT(&v) = VT_EMPTY;
3444 hres = IHTMLStyle_get_left(style, &v);
3445 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3446 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3447 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3448 VariantClear(&v);
3449
3450 /* Test posLeft */
3451 hres = IHTMLStyle_get_posLeft(style, NULL);
3452 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3453
3454 f = 1.0f;
3455 hres = IHTMLStyle_get_posLeft(style, &f);
3456 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3457 ok(f == 0.0, "expected 0.0 got %f\n", f);
3458
3459 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3460 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3461
3462 hres = IHTMLStyle_get_posLeft(style, &f);
3463 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3464 ok(f == 4.0 ||
3465 f == 4.9f, /* IE8 */
3466 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3467
3468 /* Ensure left is updated correctly. */
3469 V_VT(&v) = VT_EMPTY;
3470 hres = IHTMLStyle_get_left(style, &v);
3471 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3472 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3473 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3474 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3475 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3476 VariantClear(&v);
3477
3478 /* Test left */
3479 V_VT(&v) = VT_BSTR;
3480 V_BSTR(&v) = a2bstr("3px");
3481 hres = IHTMLStyle_put_left(style, v);
3482 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3483 VariantClear(&v);
3484
3485 hres = IHTMLStyle_get_posLeft(style, &f);
3486 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3487 ok(f == 3.0, "expected 3.0 got %f\n", f);
3488
3489 V_VT(&v) = VT_EMPTY;
3490 hres = IHTMLStyle_get_left(style, &v);
3491 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3492 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3493 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3494 VariantClear(&v);
3495
3496 V_VT(&v) = VT_NULL;
3497 hres = IHTMLStyle_put_left(style, v);
3498 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3499
3500 V_VT(&v) = VT_EMPTY;
3501 hres = IHTMLStyle_get_left(style, &v);
3502 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3503 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3504 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3505 VariantClear(&v);
3506
3507 V_VT(&v) = VT_EMPTY;
3508 hres = IHTMLStyle_get_top(style, &v);
3509 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3510 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3511 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3512 VariantClear(&v);
3513
3514 /* Test posTop */
3515 hres = IHTMLStyle_get_posTop(style, NULL);
3516 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3517
3518 f = 1.0f;
3519 hres = IHTMLStyle_get_posTop(style, &f);
3520 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3521 ok(f == 0.0, "expected 0.0 got %f\n", f);
3522
3523 hres = IHTMLStyle_put_posTop(style, 4.9f);
3524 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3525
3526 hres = IHTMLStyle_get_posTop(style, &f);
3527 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3528 ok(f == 4.0 ||
3529 f == 4.9f, /* IE8 */
3530 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3531
3532 V_VT(&v) = VT_BSTR;
3533 V_BSTR(&v) = a2bstr("3px");
3534 hres = IHTMLStyle_put_top(style, v);
3535 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3536 VariantClear(&v);
3537
3538 V_VT(&v) = VT_EMPTY;
3539 hres = IHTMLStyle_get_top(style, &v);
3540 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3541 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3542 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3543 VariantClear(&v);
3544
3545 hres = IHTMLStyle_get_posTop(style, &f);
3546 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3547 ok(f == 3.0, "expected 3.0 got %f\n", f);
3548
3549 V_VT(&v) = VT_NULL;
3550 hres = IHTMLStyle_put_top(style, v);
3551 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3552
3553 V_VT(&v) = VT_EMPTY;
3554 hres = IHTMLStyle_get_top(style, &v);
3555 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3556 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3557 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3558 VariantClear(&v);
3559
3560 /* Test posHeight */
3561 hres = IHTMLStyle_get_posHeight(style, NULL);
3562 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3563
3564 V_VT(&v) = VT_EMPTY;
3565 hres = IHTMLStyle_get_height(style, &v);
3566 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3567 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3568 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3569 VariantClear(&v);
3570
3571 f = 1.0f;
3572 hres = IHTMLStyle_get_posHeight(style, &f);
3573 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3574 ok(f == 0.0, "expected 0.0 got %f\n", f);
3575
3576 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3577 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3578
3579 hres = IHTMLStyle_get_posHeight(style, &f);
3580 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3581 ok(f == 4.0 ||
3582 f == 4.9f, /* IE8 */
3583 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3584
3585 V_VT(&v) = VT_BSTR;
3586 V_BSTR(&v) = a2bstr("64px");
3587 hres = IHTMLStyle_put_height(style, v);
3588 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3589 VariantClear(&v);
3590
3591 V_VT(&v) = VT_EMPTY;
3592 hres = IHTMLStyle_get_height(style, &v);
3593 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3594 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3595 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3596 VariantClear(&v);
3597
3598 hres = IHTMLStyle_get_posHeight(style, &f);
3599 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3600 ok(f == 64.0, "expected 64.0 got %f\n", f);
3601
3602 str = (void*)0xdeadbeef;
3603 hres = IHTMLStyle_get_cursor(style, &str);
3604 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3605 ok(!str, "get_cursor != NULL\n");
3606 SysFreeString(str);
3607
3608 str = a2bstr("default");
3609 hres = IHTMLStyle_put_cursor(style, str);
3610 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3611 SysFreeString(str);
3612
3613 str = NULL;
3614 hres = IHTMLStyle_get_cursor(style, &str);
3615 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3616 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3617 SysFreeString(str);
3618
3619 V_VT(&v) = VT_EMPTY;
3620 hres = IHTMLStyle_get_verticalAlign(style, &v);
3621 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3622 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3623 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3624 VariantClear(&v);
3625
3626 V_VT(&v) = VT_BSTR;
3627 V_BSTR(&v) = a2bstr("middle");
3628 hres = IHTMLStyle_put_verticalAlign(style, v);
3629 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3630 VariantClear(&v);
3631
3632 V_VT(&v) = VT_EMPTY;
3633 hres = IHTMLStyle_get_verticalAlign(style, &v);
3634 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3635 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3636 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3637 VariantClear(&v);
3638
3639 str = (void*)0xdeadbeef;
3640 hres = IHTMLStyle_get_textAlign(style, &str);
3641 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3642 ok(!str, "textAlign != NULL\n");
3643
3644 str = a2bstr("center");
3645 hres = IHTMLStyle_put_textAlign(style, str);
3646 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3647 SysFreeString(str);
3648
3649 str = NULL;
3650 hres = IHTMLStyle_get_textAlign(style, &str);
3651 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3652 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3653 SysFreeString(str);
3654
3655 str = (void*)0xdeadbeef;
3656 hres = IHTMLStyle_get_filter(style, &str);
3657 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3658 ok(!str, "filter != NULL\n");
3659
3660 str = a2bstr("alpha(opacity=100)");
3661 hres = IHTMLStyle_put_filter(style, str);
3662 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3663 SysFreeString(str);
3664
3665 V_VT(&v) = VT_EMPTY;
3666 hres = IHTMLStyle_get_zIndex(style, &v);
3667 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3668 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3669 ok(!V_I4(&v), "V_I4(v) != 0\n");
3670 VariantClear(&v);
3671
3672 V_VT(&v) = VT_BSTR;
3673 V_BSTR(&v) = a2bstr("1");
3674 hres = IHTMLStyle_put_zIndex(style, v);
3675 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3676 VariantClear(&v);
3677
3678 V_VT(&v) = VT_EMPTY;
3679 hres = IHTMLStyle_get_zIndex(style, &v);
3680 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3681 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3682 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3683 VariantClear(&v);
3684
3685 /* fontStyle */
3686 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3687 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3688
3689 str = a2bstr("test");
3690 hres = IHTMLStyle_put_fontStyle(style, str);
3691 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3692 SysFreeString(str);
3693
3694 str = a2bstr("italic");
3695 hres = IHTMLStyle_put_fontStyle(style, str);
3696 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3697 SysFreeString(str);
3698
3699 str = a2bstr("oblique");
3700 hres = IHTMLStyle_put_fontStyle(style, str);
3701 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3702 SysFreeString(str);
3703
3704 str = a2bstr("normal");
3705 hres = IHTMLStyle_put_fontStyle(style, str);
3706 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3707 SysFreeString(str);
3708
3709 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3710 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3711 SysFreeString(sDefault);
3712
3713 /* overflow */
3714 hres = IHTMLStyle_get_overflow(style, NULL);
3715 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3716
3717 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3718 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3719
3720 str = a2bstr("test");
3721 hres = IHTMLStyle_put_overflow(style, str);
3722 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
3723 SysFreeString(str);
3724
3725 str = a2bstr("visible");
3726 hres = IHTMLStyle_put_overflow(style, str);
3727 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3728 SysFreeString(str);
3729
3730 str = a2bstr("scroll");
3731 hres = IHTMLStyle_put_overflow(style, str);
3732 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3733 SysFreeString(str);
3734
3735 str = a2bstr("hidden");
3736 hres = IHTMLStyle_put_overflow(style, str);
3737 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3738 SysFreeString(str);
3739
3740 str = a2bstr("auto");
3741 hres = IHTMLStyle_put_overflow(style, str);
3742 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3743 SysFreeString(str);
3744
3745 hres = IHTMLStyle_get_overflow(style, &str);
3746 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3747 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
3748 SysFreeString(str);
3749
3750 str = a2bstr("");
3751 hres = IHTMLStyle_put_overflow(style, str);
3752 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3753 SysFreeString(str);
3754
3755 hres = IHTMLStyle_get_overflow(style, &str);
3756 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3757 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3758 SysFreeString(str);
3759
3760 /* restore overflow default */
3761 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
3762 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3763 SysFreeString(sOverflowDefault);
3764
3765 /* Attribute Tests*/
3766 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
3767 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3768
3769 str = a2bstr("position");
3770 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
3771 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3772
3773 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3774 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3775 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3776 VariantClear(&v);
3777
3778 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
3779 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
3780
3781 V_VT(&v) = VT_BSTR;
3782 V_BSTR(&v) = a2bstr("absolute");
3783 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3784 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3785 VariantClear(&v);
3786
3787 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3788 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3789 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3790 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3791 VariantClear(&v);
3792
3793 V_VT(&v) = VT_BSTR;
3794 V_BSTR(&v) = NULL;
3795 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3796 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3797 VariantClear(&v);
3798
3799 SysFreeString(str);
3800
3801 str = a2bstr("borderLeftStyle");
3802 test_border_styles(style, str);
3803 SysFreeString(str);
3804
3805 str = a2bstr("borderbottomstyle");
3806 test_border_styles(style, str);
3807 SysFreeString(str);
3808
3809 str = a2bstr("borderrightstyle");
3810 test_border_styles(style, str);
3811 SysFreeString(str);
3812
3813 str = a2bstr("bordertopstyle");
3814 test_border_styles(style, str);
3815 SysFreeString(str);
3816
3817 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
3818 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3819
3820 str = a2bstr("none dotted dashed solid");
3821 hres = IHTMLStyle_put_borderStyle(style, str);
3822 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3823 SysFreeString(str);
3824
3825 str = a2bstr("none dotted dashed solid");
3826 hres = IHTMLStyle_get_borderStyle(style, &str);
3827 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3828 ok(!strcmp_wa(str, "none dotted dashed solid"),
3829 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3830 SysFreeString(str);
3831
3832 str = a2bstr("double groove ridge inset");
3833 hres = IHTMLStyle_put_borderStyle(style, str);
3834 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3835 SysFreeString(str);
3836
3837 str = a2bstr("window-inset outset ridge inset");
3838 hres = IHTMLStyle_put_borderStyle(style, str);
3839 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3840 SysFreeString(str);
3841
3842 str = a2bstr("window-inset");
3843 hres = IHTMLStyle_put_borderStyle(style, str);
3844 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3845 SysFreeString(str);
3846
3847 str = a2bstr("none none none none none");
3848 hres = IHTMLStyle_put_borderStyle(style, str);
3849 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3850 SysFreeString(str);
3851
3852 str = a2bstr("invalid none none none");
3853 hres = IHTMLStyle_put_borderStyle(style, str);
3854 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3855 SysFreeString(str);
3856
3857 str = a2bstr("none invalid none none");
3858 hres = IHTMLStyle_put_borderStyle(style, str);
3859 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3860 SysFreeString(str);
3861
3862 hres = IHTMLStyle_put_borderStyle(style, sDefault);
3863 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3864 SysFreeString(sDefault);
3865
3866 /* backgoundColor */
3867 hres = IHTMLStyle_get_backgroundColor(style, &v);
3868 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
3869 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3870 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3871 VariantClear(&v);
3872
3873 /* PaddingLeft */
3874 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
3875 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3876
3877 V_VT(&v) = VT_BSTR;
3878 V_BSTR(&v) = a2bstr("10");
3879 hres = IHTMLStyle_put_paddingLeft(style, v);
3880 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3881 VariantClear(&v);
3882
3883 hres = IHTMLStyle_get_paddingLeft(style, &v);
3884 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3885 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3886
3887 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
3888 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3889
3890 /* BackgroundRepeat */
3891 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
3892 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3893
3894 str = a2bstr("invalid");
3895 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3896 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
3897 SysFreeString(str);
3898
3899 str = a2bstr("repeat");
3900 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3901 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3902 SysFreeString(str);
3903
3904 str = a2bstr("no-repeat");
3905 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3906 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3907 SysFreeString(str);
3908
3909 str = a2bstr("repeat-x");
3910 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3911 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3912 SysFreeString(str);
3913
3914 str = a2bstr("repeat-y");
3915 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3916 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3917 SysFreeString(str);
3918
3919 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
3920 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3921 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
3922 SysFreeString(str);
3923
3924 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
3925 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3926 SysFreeString(sDefault);
3927
3928 /* BorderColor */
3929 hres = IHTMLStyle_get_borderColor(style, &sDefault);
3930 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3931
3932 str = a2bstr("red green red blue");
3933 hres = IHTMLStyle_put_borderColor(style, str);
3934 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3935 SysFreeString(str);
3936
3937 hres = IHTMLStyle_get_borderColor(style, &str);
3938 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3939 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
3940 SysFreeString(str);
3941
3942 hres = IHTMLStyle_put_borderColor(style, sDefault);
3943 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3944 SysFreeString(sDefault);
3945
3946 /* BorderLeft */
3947 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
3948 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
3949
3950 str = a2bstr("thick dotted red");
3951 hres = IHTMLStyle_put_borderLeft(style, str);
3952 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3953 SysFreeString(str);
3954
3955 /* IHTMLStyle_get_borderLeft appears to have a bug where
3956 it returns the first letter of the color. So we check
3957 each style individually.
3958 */
3959 V_BSTR(&v) = NULL;
3960 hres = IHTMLStyle_get_borderLeftColor(style, &v);
3961 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3962 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3963 VariantClear(&v);
3964
3965 V_BSTR(&v) = NULL;
3966 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
3967 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3968 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3969 VariantClear(&v);
3970
3971 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
3972 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3973 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
3974 SysFreeString(str);
3975
3976 hres = IHTMLStyle_put_borderLeft(style, sDefault);
3977 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3978 SysFreeString(sDefault);
3979
3980 /* backgroundPositionX */
3981 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
3982 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3983
3984 V_VT(&v) = VT_BSTR;
3985 V_BSTR(&v) = a2bstr("10px");
3986 hres = IHTMLStyle_put_backgroundPositionX(style, v);
3987 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3988 VariantClear(&v);
3989
3990 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
3991 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3992 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3993 VariantClear(&v);
3994
3995 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
3996 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3997 VariantClear(&vDefault);
3998
3999 /* backgroundPositionY */
4000 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4001 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4002
4003 V_VT(&v) = VT_BSTR;
4004 V_BSTR(&v) = a2bstr("10px");
4005 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4006 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4007 VariantClear(&v);
4008
4009 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4010 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4011 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4012 VariantClear(&v);
4013
4014 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4015 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4016 VariantClear(&vDefault);
4017
4018 /* borderTopWidth */
4019 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4020 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4021
4022 V_VT(&v) = VT_BSTR;
4023 V_BSTR(&v) = a2bstr("10px");
4024 hres = IHTMLStyle_put_borderTopWidth(style, v);
4025 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4026 VariantClear(&v);
4027
4028 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4029 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4030 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4031 VariantClear(&v);
4032
4033 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4034 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4035 VariantClear(&vDefault);
4036
4037 /* borderRightWidth */
4038 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4039 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4040
4041 V_VT(&v) = VT_BSTR;
4042 V_BSTR(&v) = a2bstr("10");
4043 hres = IHTMLStyle_put_borderRightWidth(style, v);
4044 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4045 VariantClear(&v);
4046
4047 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4048 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4049 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4050 VariantClear(&v);
4051
4052 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4053 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4054 VariantClear(&vDefault);
4055
4056 /* borderBottomWidth */
4057 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4058 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4059
4060 V_VT(&v) = VT_BSTR;
4061 V_BSTR(&v) = a2bstr("10");
4062 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4063 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4064 VariantClear(&v);
4065
4066 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4067 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4068 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4069 VariantClear(&v);
4070
4071 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4072 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4073 VariantClear(&vDefault);
4074
4075 /* borderLeftWidth */
4076 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4077 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4078
4079 V_VT(&v) = VT_BSTR;
4080 V_BSTR(&v) = a2bstr("10");
4081 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4082 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4083 VariantClear(&v);
4084
4085 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4086 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4087 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4088 VariantClear(&v);
4089
4090 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4091 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4092 VariantClear(&vDefault);
4093
4094 /* wordSpacing */
4095 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4096 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4097
4098 V_VT(&v) = VT_BSTR;
4099 V_BSTR(&v) = a2bstr("10");
4100 hres = IHTMLStyle_put_wordSpacing(style, v);
4101 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4102 VariantClear(&v);
4103
4104 hres = IHTMLStyle_get_wordSpacing(style, &v);
4105 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4106 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4107 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4108 VariantClear(&v);
4109
4110 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4111 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4112 VariantClear(&vDefault);
4113
4114 /* letterSpacing */
4115 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4116 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4117
4118 V_VT(&v) = VT_BSTR;
4119 V_BSTR(&v) = a2bstr("11");
4120 hres = IHTMLStyle_put_letterSpacing(style, v);
4121 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4122 VariantClear(&v);
4123
4124 hres = IHTMLStyle_get_letterSpacing(style, &v);
4125 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4126 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4127 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4128 VariantClear(&v);
4129
4130 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4131 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4132 VariantClear(&vDefault);
4133
4134 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4135 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4136 if(SUCCEEDED(hres)) {
4137 test_style2(style2);
4138 IHTMLStyle2_Release(style2);
4139 }
4140
4141 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4142 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4143 if(SUCCEEDED(hres)) {
4144 test_style3(style3);
4145 IHTMLStyle3_Release(style3);
4146 }
4147
4148 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4149 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4150 if(SUCCEEDED(hres)) {
4151 test_style4(style4);
4152 IHTMLStyle4_Release(style4);
4153 }
4154 }
4155
4156 static void test_set_csstext(IHTMLStyle *style)
4157 {
4158 VARIANT v;
4159 HRESULT hres;
4160
4161 test_style_set_csstext(style, "background-color: black;");
4162
4163 hres = IHTMLStyle_get_backgroundColor(style, &v);
4164 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4165 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4166 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4167 VariantClear(&v);
4168 }
4169
4170 static void test_default_selection(IHTMLDocument2 *doc)
4171 {
4172 IHTMLSelectionObject *selection;
4173 IHTMLTxtRange *range;
4174 IDispatch *disp;
4175 BSTR str;
4176 HRESULT hres;
4177
4178 hres = IHTMLDocument2_get_selection(doc, &selection);
4179 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4180
4181 hres = IHTMLSelectionObject_get_type(selection, &str);
4182 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4183 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4184 SysFreeString(str);
4185
4186 hres = IHTMLSelectionObject_createRange(selection, &disp);
4187 IHTMLSelectionObject_Release(selection);
4188 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4189
4190 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4191 IDispatch_Release(disp);
4192 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4193
4194 test_range_text(range, NULL);
4195 IHTMLTxtRange_Release(range);
4196 }
4197
4198 static void test_doc_elem(IHTMLDocument2 *doc)
4199 {
4200 IHTMLDocument2 *doc_node, *owner_doc;
4201 IHTMLElement *elem;
4202 IHTMLDocument3 *doc3;
4203 HRESULT hres;
4204
4205 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4206 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4207
4208 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4209 IHTMLDocument3_Release(doc3);
4210 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4211
4212 test_node_name((IUnknown*)elem, "HTML");
4213 test_elem_tag((IUnknown*)elem, "HTML");
4214
4215 doc_node = get_doc_node(doc);
4216 owner_doc = get_owner_doc((IUnknown*)elem);
4217 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4218 IHTMLDocument2_Release(doc_node);
4219 IHTMLDocument2_Release(owner_doc);
4220
4221 test_elem_client_rect((IUnknown*)elem);
4222
4223 IHTMLElement_Release(elem);
4224 }
4225
4226 static void test_default_body(IHTMLBodyElement *body)
4227 {
4228 LONG l;
4229 BSTR bstr;
4230 HRESULT hres;
4231 VARIANT v;
4232 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4233 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4234
4235 bstr = (void*)0xdeadbeef;
4236 hres = IHTMLBodyElement_get_background(body, &bstr);
4237 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4238 ok(bstr == NULL, "bstr != NULL\n");
4239
4240 l = elem_get_scroll_height((IUnknown*)body);
4241 ok(l != -1, "scrollHeight == -1\n");
4242 l = elem_get_scroll_width((IUnknown*)body);
4243 ok(l != -1, "scrollWidth == -1\n");
4244 l = elem_get_scroll_top((IUnknown*)body);
4245 ok(!l, "scrollTop = %d\n", l);
4246 elem_get_scroll_left((IUnknown*)body);
4247
4248 /* get_text tests */
4249 hres = IHTMLBodyElement_get_text(body, &v);
4250 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4251 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4252 ok(bstr == NULL, "bstr != NULL\n");
4253
4254
4255 /* get_text - Invalid Text */
4256 V_VT(&v) = VT_BSTR;
4257 V_BSTR(&v) = SysAllocString(sTextInvalid);
4258 hres = IHTMLBodyElement_put_text(body, v);
4259 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4260 VariantClear(&v);
4261
4262 V_VT(&v) = VT_NULL;
4263 hres = IHTMLBodyElement_get_text(body, &v);
4264 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4265 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4266 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4267 VariantClear(&v);
4268
4269 /* get_text - Valid Text */
4270 V_VT(&v) = VT_BSTR;
4271 V_BSTR(&v) = SysAllocString(sBodyText);
4272 hres = IHTMLBodyElement_put_text(body, v);
4273 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4274 VariantClear(&v);
4275
4276 V_VT(&v) = VT_NULL;
4277 hres = IHTMLBodyElement_get_text(body, &v);
4278 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4279 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4280 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4281 VariantClear(&v);
4282 }
4283
4284 static void test_body_funs(IHTMLBodyElement *body)
4285 {
4286 static WCHAR sRed[] = {'r','e','d',0};
4287 VARIANT vbg;
4288 VARIANT vDefaultbg;
4289 HRESULT hres;
4290
4291 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4292 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4293 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4294
4295 V_VT(&vbg) = VT_BSTR;
4296 V_BSTR(&vbg) = SysAllocString(sRed);
4297 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4298 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4299 VariantClear(&vbg);
4300
4301 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4302 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4303 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4304 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4305 VariantClear(&vbg);
4306
4307 /* Restore Originial */
4308 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4309 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4310 VariantClear(&vDefaultbg);
4311 }
4312
4313 static void test_window(IHTMLDocument2 *doc)
4314 {
4315 IHTMLWindow2 *window, *window2, *self;
4316 IHTMLDocument2 *doc2 = NULL;
4317 IDispatch *disp;
4318 IUnknown *unk;
4319 BSTR str;
4320 HRESULT hres;
4321
4322 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4323 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4324 test_ifaces((IUnknown*)window, window_iids);
4325 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4326
4327 hres = IHTMLWindow2_get_document(window, &doc2);
4328 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4329 ok(doc2 != NULL, "doc2 == NULL\n");
4330
4331 test_ifaces((IUnknown*)doc2, doc_node_iids);
4332 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4333
4334 test_ifaces((IUnknown*)doc, doc_obj_iids);
4335 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4336
4337 unk = (void*)0xdeadbeef;
4338 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4339 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4340 ok(!unk, "unk = %p\n", unk);
4341
4342 IHTMLDocument_Release(doc2);
4343
4344 hres = IHTMLWindow2_get_window(window, &window2);
4345 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4346 ok(window2 != NULL, "window2 == NULL\n");
4347
4348 hres = IHTMLWindow2_get_self(window, &self);
4349 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4350 ok(window2 != NULL, "self == NULL\n");
4351
4352 ok(self == window2, "self != window2\n");
4353
4354 IHTMLWindow2_Release(window2);
4355 IHTMLWindow2_Release(self);
4356
4357 disp = NULL;
4358 hres = IHTMLDocument2_get_Script(doc, &disp);
4359 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4360 ok(disp == (void*)window, "disp != window\n");
4361 IDispatch_Release(disp);
4362
4363 hres = IHTMLWindow2_toString(window, NULL);
4364 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4365
4366 str = NULL;
4367 hres = IHTMLWindow2_toString(window, &str);
4368 ok(hres == S_OK, "toString failed: %08x\n", hres);
4369 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4370 SysFreeString(str);
4371
4372 IHTMLWindow2_Release(window);
4373 }
4374
4375 static void test_defaults(IHTMLDocument2 *doc)
4376 {
4377 IHTMLStyleSheetsCollection *stylesheetcol;
4378 IHTMLCurrentStyle *cstyle;
4379 IHTMLBodyElement *body;
4380 IHTMLElement2 *elem2;
4381 IHTMLElement *elem;
4382 IHTMLStyle *style;
4383 LONG l;
4384 HRESULT hres;
4385 IHTMLElementCollection *collection;
4386
4387 hres = IHTMLDocument2_get_body(doc, &elem);
4388 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4389
4390 hres = IHTMLDocument2_get_images(doc, NULL);
4391 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4392
4393 hres = IHTMLDocument2_get_images(doc, &collection);
4394 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4395 if(hres == S_OK)
4396 {
4397 test_elem_collection((IUnknown*)collection, NULL, 0);
4398 IHTMLElementCollection_Release(collection);
4399 }
4400
4401 hres = IHTMLDocument2_get_applets(doc, NULL);
4402 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4403
4404 hres = IHTMLDocument2_get_applets(doc, &collection);
4405 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4406 if(hres == S_OK)
4407 {
4408 test_elem_collection((IUnknown*)collection, NULL, 0);
4409 IHTMLElementCollection_Release(collection);
4410 }
4411
4412 hres = IHTMLDocument2_get_links(doc, NULL);
4413 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4414
4415 hres = IHTMLDocument2_get_links(doc, &collection);
4416 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4417 if(hres == S_OK)
4418 {
4419 test_elem_collection((IUnknown*)collection, NULL, 0);
4420 IHTMLElementCollection_Release(collection);
4421 }
4422
4423 hres = IHTMLDocument2_get_forms(doc, NULL);
4424 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4425
4426 hres = IHTMLDocument2_get_forms(doc, &collection);
4427 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4428 if(hres == S_OK)
4429 {
4430 test_elem_collection((IUnknown*)collection, NULL, 0);
4431 IHTMLElementCollection_Release(collection);
4432 }
4433
4434 hres = IHTMLDocument2_get_anchors(doc, NULL);
4435 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4436
4437 hres = IHTMLDocument2_get_anchors(doc, &collection);
4438 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4439 if(hres == S_OK)
4440 {
4441 test_elem_collection((IUnknown*)collection, NULL, 0);
4442 IHTMLElementCollection_Release(collection);
4443 }
4444
4445 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4446 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4447 test_default_body(body);
4448 test_body_funs(body);
4449 IHTMLBodyElement_Release(body);
4450
4451 hres = IHTMLElement_get_style(elem, &style);
4452 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4453
4454 test_default_style(style);
4455 test_window(doc);
4456 test_compatmode(doc);
4457 test_location(doc);
4458 test_navigator(doc);
4459
4460 elem2 = get_elem2_iface((IUnknown*)elem);
4461 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4462 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4463 if(SUCCEEDED(hres)) {
4464 test_current_style(cstyle);
4465 IHTMLCurrentStyle_Release(cstyle);
4466 }
4467 IHTMLElement2_Release(elem2);
4468
4469 IHTMLElement_Release(elem);
4470
4471 test_set_csstext(style);
4472 IHTMLStyle_Release(style);
4473
4474 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4475 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4476
4477 l = 0xdeadbeef;
4478 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4479 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4480 ok(l == 0, "length = %d\n", l);
4481
4482 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4483
4484 test_default_selection(doc);
4485 test_doc_title(doc, "");
4486 }
4487
4488 static void test_tr_elem(IHTMLElement *elem)
4489 {
4490 IHTMLElementCollection *col;
4491 IHTMLTableRow *row;
4492 HRESULT hres;
4493
4494 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4495
4496 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4497 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4498 if(FAILED(hres))
4499 return;
4500
4501 col = NULL;
4502 hres = IHTMLTableRow_get_cells(row, &col);
4503 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4504 ok(col != NULL, "get_cells returned NULL\n");
4505
4506 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4507 IHTMLElementCollection_Release(col);
4508
4509 IHTMLTable_Release(row);
4510 }
4511
4512 static void test_table_elem(IHTMLElement *elem)
4513 {
4514 IHTMLElementCollection *col;
4515 IHTMLTable *table;
4516 IHTMLDOMNode *node;
4517 HRESULT hres;
4518
4519 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4520 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4521
4522 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4523 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4524 if(FAILED(hres))
4525 return;
4526
4527 col = NULL;
4528 hres = IHTMLTable_get_rows(table, &col);
4529 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4530 ok(col != NULL, "get_ros returned NULL\n");
4531
4532 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4533 IHTMLElementCollection_Release(col);
4534
4535 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4536
4537 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4538 test_elem_tag((IUnknown*)node, "TABLE");
4539 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4540 IHTMLDOMNode_Release(node);
4541
4542 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4543 test_elem_tag((IUnknown*)node, "TABLE");
4544 test_elem_all((IUnknown*)node, NULL, 0);
4545 IHTMLDOMNode_Release(node);
4546
4547 IHTMLTable_Release(table);
4548 }
4549
4550 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4551 {
4552 SAFEARRAYBOUND dim;
4553 SAFEARRAY *sa;
4554 VARIANT *var;
4555 BSTR str;
4556 HRESULT hres;
4557
4558 dim.lLbound = 0;
4559 dim.cElements = 1;
4560 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4561 SafeArrayAccessData(sa, (void**)&var);
4562 V_VT(var) = VT_BSTR;
4563 V_BSTR(var) = str = a2bstr(text);
4564 SafeArrayUnaccessData(sa);
4565
4566 if(ln)
4567 hres = IHTMLDocument2_writeln(doc, sa);
4568 else
4569 hres = IHTMLDocument2_write(doc, sa);
4570 ok(hres == S_OK, "write failed: %08x\n", hres);
4571
4572 SysFreeString(str);
4573 SafeArrayDestroy(sa);
4574 }
4575
4576 static void test_iframe_elem(IHTMLElement *elem)
4577 {
4578 IHTMLElementCollection *col;
4579 IHTMLDocument2 *content_doc;
4580 IHTMLWindow2 *content_window;
4581 IHTMLFrameBase2 *base2;
4582 IDispatch *disp;
4583 VARIANT errv;
4584 BSTR str;
4585 HRESULT hres;
4586
4587 static const elem_type_t all_types[] = {
4588 ET_HTML,
4589 ET_HEAD,
4590 ET_TITLE,
4591 ET_BODY,
4592 ET_BR
4593 };
4594
4595 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
4596 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
4597 if (!base2) return;
4598
4599 content_window = NULL;
4600 hres = IHTMLFrameBase2_get_contentWindow(base2, &content_window);
4601 IHTMLFrameBase2_Release(base2);
4602 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
4603 ok(content_window != NULL, "contentWindow = NULL\n");
4604
4605 content_doc = NULL;
4606 hres = IHTMLWindow2_get_document(content_window, &content_doc);
4607 IHTMLWindow2_Release(content_window);
4608 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4609 ok(content_doc != NULL, "content_doc = NULL\n");
4610
4611 str = a2bstr("text/html");
4612 V_VT(&errv) = VT_ERROR;
4613 disp = NULL;
4614 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4615 SysFreeString(str);
4616 ok(hres == S_OK, "open failed: %08x\n", hres);
4617 ok(disp != NULL, "disp == NULL\n");
4618 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4619 IDispatch_Release(disp);
4620
4621 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4622 doc_write(content_doc, TRUE, "</html>");
4623
4624 hres = IHTMLDocument2_get_all(content_doc, &col);
4625 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4626 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4627 IHTMLElementCollection_Release(col);
4628
4629 hres = IHTMLDocument2_close(content_doc);
4630 ok(hres == S_OK, "close failed: %08x\n", hres);
4631
4632 IHTMLDocument2_Release(content_doc);
4633 }
4634
4635 static void test_stylesheet(IDispatch *disp)
4636 {
4637 IHTMLStyleSheetRulesCollection *col = NULL;
4638 IHTMLStyleSheet *stylesheet;
4639 HRESULT hres;
4640
4641 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4642 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4643
4644 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4645 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4646 ok(col != NULL, "col == NULL\n");
4647
4648 IHTMLStyleSheetRulesCollection_Release(col);
4649 IHTMLStyleSheet_Release(stylesheet);
4650 }
4651
4652 static void test_stylesheets(IHTMLDocument2 *doc)
4653 {
4654 IHTMLStyleSheetsCollection *col = NULL;
4655 VARIANT idx, res;
4656 LONG len = 0;
4657 HRESULT hres;
4658
4659 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4660 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4661 ok(col != NULL, "col == NULL\n");
4662
4663 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4664 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4665 ok(len == 1, "len=%d\n", len);
4666
4667 VariantInit(&res);
4668 V_VT(&idx) = VT_I4;
4669 V_I4(&idx) = 0;
4670
4671 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4672 ok(hres == S_OK, "item failed: %08x\n", hres);
4673 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4674 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4675 test_stylesheet(V_DISPATCH(&res));
4676 VariantClear(&res);
4677
4678 V_VT(&res) = VT_I4;
4679 V_VT(&idx) = VT_I4;
4680 V_I4(&idx) = 1;
4681
4682 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4683 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4684 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4685 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4686 VariantClear(&res);
4687
4688 IHTMLStyleSheetsCollection_Release(col);
4689 }
4690
4691 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4692 {
4693 IDispatchEx *dispex;
4694 IHTMLDOMNode *node;
4695 DISPPARAMS dp = {NULL, NULL, 0, 0};
4696 VARIANT var;
4697 EXCEPINFO ei;
4698 LONG type;
4699 DISPID id;
4700 BSTR bstr;
4701 HRESULT hres;
4702
4703 static const WCHAR w0[] = {'0',0};
4704 static const WCHAR w100[] = {'1','0','0',0};
4705
4706 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4707 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4708
4709 bstr = SysAllocString(w0);
4710 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4711 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4712 SysFreeString(bstr);
4713
4714 VariantInit(&var);
4715 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4716 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4717 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4718 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4719 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4720 type = get_node_type((IUnknown*)node);
4721 ok(type == 3, "type=%d\n", type);
4722 IHTMLDOMNode_Release(node);
4723 VariantClear(&var);
4724
4725 bstr = SysAllocString(w100);
4726 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4727 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4728 SysFreeString(bstr);
4729
4730 IDispatchEx_Release(dispex);
4731 }
4732
4733
4734
4735 static void test_elems(IHTMLDocument2 *doc)
4736 {
4737 IHTMLElementCollection *col;
4738 IHTMLDOMChildrenCollection *child_col;
4739 IHTMLElement *elem, *elem2, *elem3;
4740 IHTMLDOMNode *node, *node2;
4741 IDispatch *disp;
4742 LONG type;
4743 HRESULT hres;
4744 IHTMLElementCollection *collection;
4745 IHTMLDocument3 *doc3;
4746 BSTR str;
4747
4748 static const elem_type_t all_types[] = {
4749 ET_HTML,
4750 ET_HEAD,
4751 ET_TITLE,
4752 ET_STYLE,
4753 ET_BODY,
4754 ET_COMMENT,
4755 ET_A,
4756 ET_INPUT,
4757 ET_SELECT,
4758 ET_OPTION,
4759 ET_OPTION,
4760 ET_TEXTAREA,
4761 ET_TABLE,
4762 ET_TBODY,
4763 ET_TR,
4764 ET_TR,
4765 ET_TD,
4766 ET_TD,
4767 ET_SCRIPT,
4768 ET_TEST,
4769 ET_IMG,
4770 ET_IFRAME
4771 };
4772
4773 static const elem_type_t item_types[] = {
4774 ET_A,
4775 ET_OPTION,
4776 ET_TEXTAREA
4777 };
4778
4779 hres = IHTMLDocument2_get_all(doc, &col);
4780 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4781 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4782 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
4783 IHTMLElementCollection_Release(col);
4784
4785 hres = IHTMLDocument2_get_images(doc, &collection);
4786 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4787 if(hres == S_OK)
4788 {
4789 static const elem_type_t images_types[] = {ET_IMG};
4790 test_elem_collection((IUnknown*)collection, images_types, 1);
4791
4792 IHTMLElementCollection_Release(collection);
4793 }
4794
4795 hres = IHTMLDocument2_get_links(doc, &collection);
4796 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4797 if(hres == S_OK)
4798 {
4799 static const elem_type_t images_types[] = {ET_A};
4800 test_elem_collection((IUnknown*)collection, images_types, 1);
4801
4802 IHTMLElementCollection_Release(collection);
4803 }
4804
4805 hres = IHTMLDocument2_get_anchors(doc, &collection);
4806 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4807 if(hres == S_OK)
4808 {
4809 static const elem_type_t anchor_types[] = {ET_A};
4810 test_elem_collection((IUnknown*)collection, anchor_types, 1);
4811
4812 IHTMLElementCollection_Release(collection);
4813 }
4814
4815 elem = get_doc_elem(doc);
4816 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
4817 IHTMLElement_Release(elem);
4818
4819 get_elem_by_id(doc, "xxx", FALSE);
4820 elem = get_doc_elem_by_id(doc, "xxx");
4821 ok(!elem, "elem != NULL\n");
4822
4823 elem = get_doc_elem_by_id(doc, "s");
4824 ok(elem != NULL, "elem == NULL\n");
4825 if(elem) {
4826 test_elem_type((IUnknown*)elem, ET_SELECT);
4827 test_elem_attr(elem, "xxx", NULL);
4828 test_elem_attr(elem, "id", "s");
4829 test_elem_class((IUnknown*)elem, NULL);
4830 test_elem_set_class((IUnknown*)elem, "cl");
4831 test_elem_set_class((IUnknown*)elem, NULL);
4832 test_elem_tabindex((IUnknown*)elem, 0);
4833 test_elem_set_tabindex((IUnknown*)elem, 1);
4834
4835 node = test_node_get_parent((IUnknown*)elem);
4836 ok(node != NULL, "node == NULL\n");
4837 test_node_name((IUnknown*)node, "BODY");
4838 node2 = test_node_get_parent((IUnknown*)node);
4839 IHTMLDOMNode_Release(node);
4840 ok(node2 != NULL, "node == NULL\n");
4841 test_node_name((IUnknown*)node2, "HTML");
4842 node = test_node_get_parent((IUnknown*)node2);
4843 IHTMLDOMNode_Release(node2);
4844 ok(node != NULL, "node == NULL\n");
4845 if (node)
4846 {
4847 test_node_name((IUnknown*)node, "#document");
4848 type = get_node_type((IUnknown*)node);
4849 ok(type == 9, "type=%d, expected 9\n", type);
4850 node2 = test_node_get_parent((IUnknown*)node);
4851 IHTMLDOMNode_Release(node);
4852 ok(node2 == NULL, "node != NULL\n");
4853 }
4854
4855 elem2 = test_elem_get_parent((IUnknown*)elem);
4856 ok(elem2 != NULL, "elem2 == NULL\n");
4857 test_node_name((IUnknown*)elem2, "BODY");
4858 elem3 = test_elem_get_parent((IUnknown*)elem2);
4859 IHTMLElement_Release(elem2);
4860 ok(elem3 != NULL, "elem3 == NULL\n");
4861 test_node_name((IUnknown*)elem3, "HTML");
4862 elem2 = test_elem_get_parent((IUnknown*)elem3);
4863 IHTMLElement_Release(elem3);
4864 ok(elem2 == NULL, "elem2 != NULL\n");
4865
4866 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
4867 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
4868 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
4869
4870 test_elem_innertext(elem, "opt1opt2");
4871
4872 IHTMLElement_Release(elem);
4873 }
4874
4875 elem = get_elem_by_id(doc, "s", TRUE);
4876 if(elem) {
4877 IHTMLSelectElement *select;
4878 IHTMLDocument2 *doc_node;
4879
4880 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
4881 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
4882
4883 test_select_elem(select);
4884
4885 test_elem_title((IUnknown*)select, NULL);
4886 test_elem_set_title((IUnknown*)select, "Title");
4887 test_elem_title((IUnknown*)select, "Title");
4888 test_elem_offset((IUnknown*)select);
4889
4890 node = get_first_child((IUnknown*)select);
4891 ok(node != NULL, "node == NULL\n");
4892 if(node) {
4893 test_elem_type((IUnknown*)node, ET_OPTION);
4894 IHTMLDOMNode_Release(node);
4895 }
4896
4897 type = get_node_type((IUnknown*)select);
4898 ok(type == 1, "type=%d\n", type);
4899
4900 IHTMLSelectElement_Release(select);
4901
4902 hres = IHTMLElement_get_document(elem, &disp);
4903 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4904
4905 doc_node = get_doc_node(doc);
4906 ok(iface_cmp((IUnknown*)disp, (IUnknown*)doc_node), "disp != doc\n");
4907 IHTMLDocument2_Release(doc_node);
4908
4909 IHTMLElement_Release(elem);
4910 }
4911
4912 elem = get_elem_by_id(doc, "sc", TRUE);
4913 if(elem) {
4914 IHTMLScriptElement *script;
4915 BSTR type;
4916
4917 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
4918 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
4919
4920 if(hres == S_OK)
4921 {
4922 VARIANT_BOOL vb;
4923
4924 hres = IHTMLScriptElement_get_type(script, &type);
4925 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4926 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
4927 SysFreeString(type);
4928
4929 /* test defer */
4930 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
4931 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4932
4933 hres = IHTMLScriptElement_get_defer(script, &vb);
4934 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
4935 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
4936
4937 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
4938 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4939 }
4940
4941 IHTMLScriptElement_Release(script);
4942 }
4943
4944 elem = get_elem_by_id(doc, "in", TRUE);
4945 if(elem) {
4946 IHTMLInputElement *input;
4947
4948 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
4949 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
4950
4951 test_elem_id((IUnknown*)elem, "in");
4952 test_elem_put_id((IUnknown*)elem, "newin");
4953 test_input_get_disabled(input, VARIANT_FALSE);
4954 test_input_set_disabled(input, VARIANT_TRUE);
4955 test_input_set_disabled(input, VARIANT_FALSE);
4956 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
4957 test_input_get_disabled(input, VARIANT_TRUE);
4958 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
4959 test_input_get_disabled(input, VARIANT_FALSE);
4960 test_elem_client_size((IUnknown*)elem);
4961
4962 test_node_get_value_str((IUnknown*)elem, NULL);
4963 test_node_put_value_str((IUnknown*)elem, "test");
4964 test_node_get_value_str((IUnknown*)elem, NULL);
4965 test_input_value((IUnknown*)elem, NULL);
4966 test_input_put_value((IUnknown*)elem, "test");
4967 test_input_value((IUnknown*)elem, NULL);
4968 test_elem_class((IUnknown*)elem, "testclass");
4969 test_elem_tabindex((IUnknown*)elem, 2);
4970 test_elem_set_tabindex((IUnknown*)elem, 3);
4971 test_elem_title((IUnknown*)elem, "test title");
4972
4973 test_input_get_defaultchecked(input, VARIANT_FALSE);
4974 test_input_set_defaultchecked(input, VARIANT_TRUE);
4975 test_input_set_defaultchecked(input, VARIANT_FALSE);
4976
4977 test_input_get_checked(input, VARIANT_FALSE);
4978 test_input_set_checked(input, VARIANT_TRUE);
4979 test_input_set_checked(input, VARIANT_FALSE);
4980
4981 test_input_src(input, NULL);
4982 test_input_set_src(input, "about:blank");
4983
4984 IHTMLInputElement_Release(input);
4985 IHTMLElement_Release(elem);
4986 }
4987
4988 elem = get_elem_by_id(doc, "imgid", TRUE);
4989 if(elem) {
4990 test_img_src((IUnknown*)elem, "");
4991 test_img_set_src((IUnknown*)elem, "about:blank");
4992 test_img_alt((IUnknown*)elem, NULL);
4993 test_img_set_alt((IUnknown*)elem, "alt test");
4994 IHTMLElement_Release(elem);
4995 }
4996
4997 elem = get_doc_elem_by_id(doc, "tbl");
4998 ok(elem != NULL, "elem == NULL\n");
4999 if(elem) {
5000 test_table_elem(elem);
5001 IHTMLElement_Release(elem);
5002 }
5003
5004 elem = get_doc_elem_by_id(doc, "row2");
5005 ok(elem != NULL, "elem == NULL\n");
5006 if(elem) {
5007 test_tr_elem(elem);
5008 IHTMLElement_Release(elem);
5009 }
5010
5011 elem = get_doc_elem_by_id(doc, "ifr");
5012 ok(elem != NULL, "elem == NULL\n");
5013 if(elem) {
5014 test_iframe_elem(elem);
5015 IHTMLElement_Release(elem);
5016 }
5017
5018 elem = get_elem_by_id(doc, "a", TRUE);
5019 if(elem) {
5020 test_anchor_href((IUnknown*)elem, "http://test/");
5021 IHTMLElement_Release(elem);
5022 }
5023
5024 hres = IHTMLDocument2_get_body(doc, &elem);
5025 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5026
5027 node = get_first_child((IUnknown*)elem);
5028 ok(node != NULL, "node == NULL\n");
5029 if(node) {
5030 test_ifaces((IUnknown*)node, text_iids);
5031 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5032
5033 node2 = get_first_child((IUnknown*)node);
5034 ok(!node2, "node2 != NULL\n");
5035
5036 type = get_node_type((IUnknown*)node);
5037 ok(type == 3, "type=%d\n", type);
5038
5039 test_node_get_value_str((IUnknown*)node, "text test");
5040 test_node_put_value_str((IUnknown*)elem, "test text");
5041 test_node_get_value_str((IUnknown*)node, "text test");
5042
5043 IHTMLDOMNode_Release(node);
5044 }
5045
5046 child_col = get_child_nodes((IUnknown*)elem);
5047 ok(child_col != NULL, "child_coll == NULL\n");
5048 if(child_col) {
5049 LONG length = 0;
5050
5051 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5052
5053 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5054 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5055 ok(length, "length=0\n");
5056
5057 node = get_child_item(child_col, 0);
5058 ok(node != NULL, "node == NULL\n");
5059 if(node) {
5060 type = get_node_type((IUnknown*)node);
5061 ok(type == 3, "type=%d\n", type);
5062 IHTMLDOMNode_Release(node);
5063 }
5064
5065 node = get_child_item(child_col, 1);
5066 ok(node != NULL, "node == NULL\n");
5067 if(node) {
5068 type = get_node_type((IUnknown*)node);
5069 ok(type == 8, "type=%d\n", type);
5070
5071 test_elem_id((IUnknown*)node, NULL);
5072 IHTMLDOMNode_Release(node);
5073 }
5074
5075 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5076 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5077
5078 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5079 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5080
5081 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5082 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5083
5084 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5085 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5086
5087 test_child_col_disp(child_col);
5088
5089 IHTMLDOMChildrenCollection_Release(child_col);
5090 }
5091
5092 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5093 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5094 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5095
5096 IHTMLElement_Release(elem);
5097
5098 test_stylesheets(doc);
5099 test_create_option_elem(doc);
5100
5101 elem = get_doc_elem_by_id(doc, "tbl");
5102 ok(elem != NULL, "elem = NULL\n");
5103 test_elem_set_innertext(elem, "inner text");
5104 IHTMLElement_Release(elem);
5105
5106 test_doc_title(doc, "test");
5107 test_doc_set_title(doc, "test title");
5108 test_doc_title(doc, "test title");
5109
5110 disp = NULL;
5111 hres = IHTMLDocument2_get_Script(doc, &disp);
5112 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5113 if(hres == S_OK)
5114 {
5115 IDispatchEx *dispex;
5116 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5117 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5118 if(hres == S_OK)
5119 {
5120 DISPID pid = -1;
5121 BSTR str = a2bstr("Testing");
5122 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5123 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5124 ok(pid != -1, "pid == -1\n");
5125 SysFreeString(str);
5126 IDispatchEx_Release(dispex);
5127 }
5128 }
5129 IDispatch_Release(disp);
5130
5131 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5132 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5133
5134 str = a2bstr("img");
5135 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5136 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5137 SysFreeString(str);
5138 if(hres == S_OK)
5139 {
5140 static const elem_type_t img_types[] = { ET_IMG };
5141
5142 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5143 IHTMLElementCollection_Release(col);
5144 }
5145
5146 elem = get_doc_elem_by_id(doc, "y");
5147 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5148 test_elem_innerhtml((IUnknown*)elem, "inner html");
5149 test_elem_set_innerhtml((IUnknown*)elem, "");
5150 test_elem_innerhtml((IUnknown*)elem, NULL);
5151 IHTMLElement_Release(elem);
5152
5153 IHTMLDocument3_Release(doc3);
5154 }
5155
5156 static void test_create_elems(IHTMLDocument2 *doc)
5157 {
5158 IHTMLElement *elem, *body, *elem2;
5159 IHTMLDOMNode *node, *node2, *node3, *comment;
5160 IHTMLDocument5 *doc5;
5161 IDispatch *disp;
5162 VARIANT var;
5163 LONG type;
5164 HRESULT hres;
5165 BSTR str;
5166
5167 static const elem_type_t types1[] = { ET_TESTG };
5168
5169 elem = test_create_elem(doc, "TEST");
5170 test_elem_tag((IUnknown*)elem, "TEST");
5171 type = get_node_type((IUnknown*)elem);
5172 ok(type == 1, "type=%d\n", type);
5173 test_ifaces((IUnknown*)elem, elem_iids);
5174 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5175
5176 hres = IHTMLDocument2_get_body(doc, &body);
5177 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5178 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5179
5180 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5181 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5182 elem2 = get_elem_iface((IUnknown*)node);
5183 IHTMLElement_Release(elem2);
5184
5185 hres = IHTMLElement_get_all(body, &disp);
5186 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5187 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5188 IDispatch_Release(disp);
5189
5190 test_node_remove_child((IUnknown*)body, node);
5191
5192 hres = IHTMLElement_get_all(body, &disp);
5193 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5194 test_elem_collection((IUnknown*)disp, NULL, 0);
5195 IDispatch_Release(disp);
5196 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5197
5198 IHTMLElement_Release(elem);
5199 IHTMLDOMNode_Release(node);
5200
5201 node = test_create_text(doc, "test");
5202 test_ifaces((IUnknown*)node, text_iids);
5203 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5204
5205 V_VT(&var) = VT_NULL;
5206 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5207 IHTMLDOMNode_Release(node);
5208
5209 node = test_create_text(doc, "insert ");
5210
5211 V_VT(&var) = VT_DISPATCH;
5212 V_DISPATCH(&var) = (IDispatch*)node2;
5213 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5214 IHTMLDOMNode_Release(node);
5215 IHTMLDOMNode_Release(node2);
5216 IHTMLDOMNode_Release(node3);
5217
5218 test_elem_innertext(body, "insert test");
5219 test_elem_innerhtml((IUnknown*)body, "insert test");
5220
5221 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5222 if(hres == S_OK)
5223 {
5224 str = a2bstr("testing");
5225 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5226 SysFreeString(str);
5227 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5228 if(hres == S_OK)
5229 {
5230 type = get_node_type((IUnknown*)comment);
5231 ok(type == 8, "type=%d, expected 8\n", type);
5232
5233 test_node_get_value_str((IUnknown*)comment, "testing");
5234
5235 IHTMLDOMNode_Release(comment);
5236 }
5237
5238 IHTMLDocument5_Release(doc5);
5239 }
5240
5241 IHTMLElement_Release(body);
5242 }
5243
5244 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5245 {
5246 IOleCommandTarget *cmdtrg;
5247 HRESULT hres;
5248
5249 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5250 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5251
5252 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5253 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5254
5255 IOleCommandTarget_Release(cmdtrg);
5256 }
5257
5258 static void test_indent(IHTMLDocument2 *doc)
5259 {
5260 IHTMLElementCollection *col;
5261 IHTMLTxtRange *range;
5262 HRESULT hres;
5263
5264 static const elem_type_t all_types[] = {
5265 ET_HTML,
5266 ET_HEAD,
5267 ET_TITLE,
5268 ET_BODY,
5269 ET_BR,
5270 ET_A,
5271 };
5272
5273 static const elem_type_t indent_types[] = {
5274 ET_HTML,
5275 ET_HEAD,
5276 ET_TITLE,
5277 ET_BODY,
5278 ET_BLOCKQUOTE,
5279 ET_P,
5280 ET_BR,
5281 ET_A,
5282 };
5283
5284 hres = IHTMLDocument2_get_all(doc, &col);
5285 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5286 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5287 IHTMLElementCollection_Release(col);
5288
5289 range = test_create_body_range(doc);
5290 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5291 IHTMLTxtRange_Release(range);
5292
5293 hres = IHTMLDocument2_get_all(doc, &col);
5294 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5295 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5296 IHTMLElementCollection_Release(col);
5297 }
5298
5299 static void test_cond_comment(IHTMLDocument2 *doc)
5300 {
5301 IHTMLElementCollection *col;
5302 HRESULT hres;
5303
5304 static const elem_type_t all_types[] = {
5305 ET_HTML,
5306 ET_HEAD,
5307 ET_TITLE,
5308 ET_BODY,
5309 ET_BR
5310 };
5311
5312 hres = IHTMLDocument2_get_all(doc, &col);
5313 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5314 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5315 IHTMLElementCollection_Release(col);
5316 }
5317
5318 static IHTMLDocument2 *notif_doc;
5319 static BOOL doc_complete;
5320
5321 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5322 REFIID riid, void**ppv)
5323 {
5324 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5325 *ppv = iface;
5326 return S_OK;
5327 }
5328
5329 ok(0, "unexpected call\n");
5330 return E_NOINTERFACE;
5331 }
5332
5333 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5334 {
5335 return 2;
5336 }
5337
5338 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5339 {
5340 return 1;
5341 }
5342
5343 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5344 {
5345 if(dispID == DISPID_READYSTATE){
5346 BSTR state;
5347 HRESULT hres;
5348
5349 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5350 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5351
5352 if(!strcmp_wa(state, "complete"))
5353 doc_complete = TRUE;
5354
5355 SysFreeString(state);
5356 }
5357
5358 return S_OK;
5359 }
5360
5361 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5362 {
5363 ok(0, "unexpected call\n");
5364 return E_NOTIMPL;
5365 }
5366
5367 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5368 PropertyNotifySink_QueryInterface,
5369 PropertyNotifySink_AddRef,
5370 PropertyNotifySink_Release,
5371 PropertyNotifySink_OnChanged,
5372 PropertyNotifySink_OnRequestEdit
5373 };
5374
5375 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5376
5377 static IHTMLDocument2 *create_doc_with_string(const char *str)
5378 {
5379 IPersistStreamInit *init;
5380 IStream *stream;
5381 IHTMLDocument2 *doc;
5382 HGLOBAL mem;
5383 SIZE_T len;
5384
5385 notif_doc = doc = create_document();
5386 if(!doc)
5387 return NULL;
5388
5389 doc_complete = FALSE;
5390 len = strlen(str);
5391 mem = GlobalAlloc(0, len);
5392 memcpy(mem, str, len);
5393 CreateStreamOnHGlobal(mem, TRUE, &stream);
5394
5395 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5396
5397 IPersistStreamInit_Load(init, stream);
5398 IPersistStreamInit_Release(init);
5399 IStream_Release(stream);
5400
5401 return doc;
5402 }
5403
5404 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5405 {
5406 IConnectionPointContainer *container;
5407 IConnectionPoint *cp;
5408 DWORD cookie;
5409 HRESULT hres;
5410
5411 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
5412 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
5413
5414 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5415 IConnectionPointContainer_Release(container);
5416 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
5417
5418 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
5419 IConnectionPoint_Release(cp);
5420 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5421 }
5422
5423 typedef void (*domtest_t)(IHTMLDocument2*);
5424
5425 static void run_domtest(const char *str, domtest_t test)
5426 {
5427 IHTMLDocument2 *doc;
5428 IHTMLElement *body = NULL;
5429 ULONG ref;
5430 MSG msg;
5431 HRESULT hres;
5432
5433 doc = create_doc_with_string(str);
5434 if(!doc)
5435 return;
5436
5437 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
5438
5439 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
5440 TranslateMessage(&msg);
5441 DispatchMessage(&msg);
5442 }
5443
5444 hres = IHTMLDocument2_get_body(doc, &body);
5445 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5446
5447 if(body) {
5448 IHTMLElement_Release(body);
5449 test(doc);
5450 }else {
5451 skip("Could not get document body. Assuming no Gecko installed.\n");
5452 }
5453
5454 ref = IHTMLDocument2_Release(doc);
5455 ok(!ref ||
5456 ref == 1, /* Vista */
5457 "ref = %d\n", ref);
5458 }
5459
5460 static void gecko_installer_workaround(BOOL disable)
5461 {
5462 HKEY hkey;
5463 DWORD res;
5464
5465 static BOOL has_url = FALSE;
5466 static char url[2048];
5467
5468 if(!disable && !has_url)
5469 return;
5470
5471 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
5472 if(res != ERROR_SUCCESS)
5473 return;
5474
5475 if(disable) {
5476 DWORD type, size = sizeof(url);
5477
5478 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
5479 if(res == ERROR_SUCCESS && type == REG_SZ)
5480 has_url = TRUE;
5481
5482 RegDeleteValue(hkey, "GeckoUrl");
5483 }else {
5484 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
5485 }
5486
5487 RegCloseKey(hkey);
5488 }
5489
5490 START_TEST(dom)
5491 {
5492 gecko_installer_workaround(TRUE);
5493 CoInitialize(NULL);
5494
5495 run_domtest(doc_str1, test_doc_elem);
5496 run_domtest(doc_str1, test_get_set_attr);
5497 run_domtest(range_test_str, test_txtrange);
5498 run_domtest(range_test2_str, test_txtrange2);
5499 if (winetest_interactive || ! is_ie_hardened()) {
5500 run_domtest(elem_test_str, test_elems);
5501 }else {
5502 skip("IE running in Enhanced Security Configuration\n");
5503 }
5504 run_domtest(doc_blank, test_create_elems);
5505 run_domtest(doc_blank, test_defaults);
5506 run_domtest(indent_test_str, test_indent);
5507 run_domtest(cond_comment_str, test_cond_comment);
5508
5509 CoUninitialize();
5510 gecko_installer_workaround(FALSE);
5511 }