1 /* 2 * XML test 3 * 4 * Copyright 2010-2012 Nikolay Sivov for CodeWeavers 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 */ 20 21 #include "precomp.h" 22 23 #define EXPECT_HR(hr,hr_exp) \ 24 ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp) 25 26 #define EXPECT_REF(node,ref) _expect_ref((IUnknown*)node, ref, __LINE__) 27 static void _expect_ref(IUnknown* obj, ULONG ref, int line) 28 { 29 ULONG rc; 30 IUnknown_AddRef(obj); 31 rc = IUnknown_Release(obj); 32 ok_(__FILE__, line)(rc == ref, "expected refcount %d, got %d\n", ref, rc); 33 } 34 35 DEFINE_GUID(SID_SContainerDispatch, 0xb722be00, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70); 36 DEFINE_GUID(SID_UnknownSID, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0, 0x4f, 0xa0, 0xfb, 0xa3); 37 38 static BOOL g_enablecallchecks; 39 40 #define DEFINE_EXPECT(func) \ 41 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE 42 43 #define SET_EXPECT(func) \ 44 expect_ ## func = TRUE 45 46 #define CHECK_EXPECT2(func) \ 47 do { \ 48 if (g_enablecallchecks) \ 49 ok(expect_ ##func, "unexpected call " #func "\n"); \ 50 called_ ## func = TRUE; \ 51 }while(0) 52 53 #define CHECK_CALLED(func) \ 54 do { \ 55 ok(called_ ## func, "expected " #func "\n"); \ 56 expect_ ## func = called_ ## func = FALSE; \ 57 }while(0) 58 59 /* object site */ 60 DEFINE_EXPECT(site_qi_IServiceProvider); 61 DEFINE_EXPECT(site_qi_IXMLDOMDocument); 62 DEFINE_EXPECT(site_qi_IOleClientSite); 63 64 DEFINE_EXPECT(sp_queryservice_SID_SBindHost); 65 DEFINE_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2); 66 DEFINE_EXPECT(sp_queryservice_SID_secmgr_htmldoc2); 67 DEFINE_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc); 68 DEFINE_EXPECT(sp_queryservice_SID_secmgr_secmgr); 69 70 DEFINE_EXPECT(htmldoc2_get_all); 71 DEFINE_EXPECT(htmldoc2_get_url); 72 DEFINE_EXPECT(collection_get_length); 73 74 static int g_unexpectedcall, g_expectedcall; 75 76 static BSTR alloc_str_from_narrow(const char *str) 77 { 78 int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); 79 BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */ 80 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len-1); 81 return ret; 82 } 83 84 static BSTR alloced_bstrs[256]; 85 static int alloced_bstrs_count; 86 87 static BSTR _bstr_(const char *str) 88 { 89 if(!str) 90 return NULL; 91 92 assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0])); 93 alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str); 94 return alloced_bstrs[alloced_bstrs_count++]; 95 } 96 97 static void free_bstrs(void) 98 { 99 int i; 100 for (i = 0; i < alloced_bstrs_count; i++) 101 SysFreeString(alloced_bstrs[i]); 102 alloced_bstrs_count = 0; 103 } 104 105 static BSTR a2bstr(const char *str) 106 { 107 BSTR ret; 108 int len; 109 110 if(!str) 111 return NULL; 112 113 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); 114 ret = SysAllocStringLen(NULL, len); 115 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); 116 117 return ret; 118 } 119 120 121 /* test IHTMLElementCollection */ 122 static HRESULT WINAPI htmlecoll_QueryInterface(IHTMLElementCollection *iface, REFIID riid, void **ppvObject) 123 { 124 ok(0, "unexpected call\n"); 125 *ppvObject = NULL; 126 return E_NOINTERFACE; 127 } 128 129 static ULONG WINAPI htmlecoll_AddRef(IHTMLElementCollection *iface) 130 { 131 return 2; 132 } 133 134 static ULONG WINAPI htmlecoll_Release(IHTMLElementCollection *iface) 135 { 136 return 1; 137 } 138 139 static HRESULT WINAPI htmlecoll_GetTypeInfoCount(IHTMLElementCollection *iface, UINT *pctinfo) 140 { 141 ok(0, "unexpected call\n"); 142 return E_NOTIMPL; 143 } 144 145 static HRESULT WINAPI htmlecoll_GetTypeInfo(IHTMLElementCollection *iface, UINT iTInfo, 146 LCID lcid, ITypeInfo **ppTInfo) 147 { 148 ok(0, "unexpected call\n"); 149 return E_NOTIMPL; 150 } 151 152 static HRESULT WINAPI htmlecoll_GetIDsOfNames(IHTMLElementCollection *iface, REFIID riid, 153 LPOLESTR *rgszNames, UINT cNames, 154 LCID lcid, DISPID *rgDispId) 155 { 156 ok(0, "unexpected call\n"); 157 return E_NOTIMPL; 158 } 159 160 static HRESULT WINAPI htmlecoll_Invoke(IHTMLElementCollection *iface, DISPID dispIdMember, 161 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, 162 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) 163 { 164 ok(0, "unexpected call\n"); 165 return E_NOTIMPL; 166 } 167 168 static HRESULT WINAPI htmlecoll_toString(IHTMLElementCollection *iface, BSTR *String) 169 { 170 ok(0, "unexpected call\n"); 171 return E_NOTIMPL; 172 } 173 174 static HRESULT WINAPI htmlecoll_put_length(IHTMLElementCollection *iface, LONG v) 175 { 176 ok(0, "unexpected call\n"); 177 return E_NOTIMPL; 178 } 179 180 static HRESULT WINAPI htmlecoll_get_length(IHTMLElementCollection *iface, LONG *v) 181 { 182 CHECK_EXPECT2(collection_get_length); 183 return E_NOTIMPL; 184 } 185 186 static HRESULT WINAPI htmlecoll_get__newEnum(IHTMLElementCollection *iface, IUnknown **p) 187 { 188 ok(0, "unexpected call\n"); 189 return E_NOTIMPL; 190 } 191 192 static HRESULT WINAPI htmlecoll_item(IHTMLElementCollection *iface, VARIANT name, VARIANT index, IDispatch **pdisp) 193 { 194 ok(0, "unexpected call\n"); 195 return E_NOTIMPL; 196 } 197 198 static HRESULT WINAPI htmlecoll_tags(IHTMLElementCollection *iface, VARIANT tagName, IDispatch **pdisp) 199 { 200 ok(0, "unexpected call\n"); 201 return E_NOTIMPL; 202 } 203 204 static const IHTMLElementCollectionVtbl TestHTMLECollectionVtbl = { 205 htmlecoll_QueryInterface, 206 htmlecoll_AddRef, 207 htmlecoll_Release, 208 htmlecoll_GetTypeInfoCount, 209 htmlecoll_GetTypeInfo, 210 htmlecoll_GetIDsOfNames, 211 htmlecoll_Invoke, 212 htmlecoll_toString, 213 htmlecoll_put_length, 214 htmlecoll_get_length, 215 htmlecoll_get__newEnum, 216 htmlecoll_item, 217 htmlecoll_tags 218 }; 219 220 static IHTMLElementCollection htmlecoll = { &TestHTMLECollectionVtbl }; 221 222 /* test IHTMLDocument2 */ 223 static HRESULT WINAPI htmldoc2_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppvObject) 224 { 225 trace("\n"); 226 *ppvObject = NULL; 227 return E_NOINTERFACE; 228 } 229 230 static ULONG WINAPI htmldoc2_AddRef(IHTMLDocument2 *iface) 231 { 232 return 2; 233 } 234 235 static ULONG WINAPI htmldoc2_Release(IHTMLDocument2 *iface) 236 { 237 return 1; 238 } 239 240 static HRESULT WINAPI htmldoc2_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo) 241 { 242 ok(0, "unexpected call\n"); 243 return E_NOTIMPL; 244 } 245 246 static HRESULT WINAPI htmldoc2_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo, 247 LCID lcid, ITypeInfo **ppTInfo) 248 { 249 ok(0, "unexpected call\n"); 250 return E_NOTIMPL; 251 } 252 253 static HRESULT WINAPI htmldoc2_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid, 254 LPOLESTR *rgszNames, UINT cNames, 255 LCID lcid, DISPID *rgDispId) 256 { 257 ok(0, "unexpected call\n"); 258 return E_NOTIMPL; 259 } 260 261 static HRESULT WINAPI htmldoc2_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember, 262 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, 263 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) 264 { 265 ok(0, "unexpected call\n"); 266 return E_NOTIMPL; 267 } 268 269 static HRESULT WINAPI htmldoc2_get_Script(IHTMLDocument2 *iface, IDispatch **p) 270 { 271 ok(0, "unexpected call\n"); 272 return E_NOTIMPL; 273 } 274 275 static HRESULT WINAPI htmldoc2_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p) 276 { 277 CHECK_EXPECT2(htmldoc2_get_all); 278 *p = &htmlecoll; 279 return S_OK; 280 } 281 282 static HRESULT WINAPI htmldoc2_get_body(IHTMLDocument2 *iface, IHTMLElement **p) 283 { 284 ok(0, "unexpected call\n"); 285 return E_NOTIMPL; 286 } 287 288 static HRESULT WINAPI htmldoc2_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p) 289 { 290 ok(0, "unexpected call\n"); 291 return E_NOTIMPL; 292 } 293 294 static HRESULT WINAPI htmldoc2_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p) 295 { 296 ok(0, "unexpected call\n"); 297 return E_NOTIMPL; 298 } 299 300 static HRESULT WINAPI htmldoc2_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p) 301 { 302 ok(0, "unexpected call\n"); 303 return E_NOTIMPL; 304 } 305 306 static HRESULT WINAPI htmldoc2_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p) 307 { 308 ok(0, "unexpected call\n"); 309 return E_NOTIMPL; 310 } 311 312 static HRESULT WINAPI htmldoc2_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p) 313 { 314 ok(0, "unexpected call\n"); 315 return E_NOTIMPL; 316 } 317 318 static HRESULT WINAPI htmldoc2_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p) 319 { 320 ok(0, "unexpected call\n"); 321 return E_NOTIMPL; 322 } 323 324 static HRESULT WINAPI htmldoc2_put_title(IHTMLDocument2 *iface, BSTR v) 325 { 326 ok(0, "unexpected call\n"); 327 return E_NOTIMPL; 328 } 329 330 static HRESULT WINAPI htmldoc2_get_title(IHTMLDocument2 *iface, BSTR *p) 331 { 332 ok(0, "unexpected call\n"); 333 return E_NOTIMPL; 334 } 335 336 static HRESULT WINAPI htmldoc2_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p) 337 { 338 ok(0, "unexpected call\n"); 339 return E_NOTIMPL; 340 } 341 342 static HRESULT WINAPI htmldoc2_put_designMode(IHTMLDocument2 *iface, BSTR v) 343 { 344 ok(0, "unexpected call\n"); 345 return E_NOTIMPL; 346 } 347 348 static HRESULT WINAPI htmldoc2_get_designMode(IHTMLDocument2 *iface, BSTR *p) 349 { 350 ok(0, "unexpected call\n"); 351 return E_NOTIMPL; 352 } 353 354 static HRESULT WINAPI htmldoc2_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p) 355 { 356 ok(0, "unexpected call\n"); 357 return E_NOTIMPL; 358 } 359 360 static HRESULT WINAPI htmldoc2_get_readyState(IHTMLDocument2 *iface, BSTR *p) 361 { 362 ok(0, "unexpected call\n"); 363 return E_NOTIMPL; 364 } 365 366 static HRESULT WINAPI htmldoc2_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p) 367 { 368 ok(0, "unexpected call\n"); 369 return E_NOTIMPL; 370 } 371 372 static HRESULT WINAPI htmldoc2_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p) 373 { 374 ok(0, "unexpected call\n"); 375 return E_NOTIMPL; 376 } 377 378 static HRESULT WINAPI htmldoc2_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p) 379 { 380 ok(0, "unexpected call\n"); 381 return E_NOTIMPL; 382 } 383 384 static HRESULT WINAPI htmldoc2_put_alinkColor(IHTMLDocument2 *iface, VARIANT v) 385 { 386 ok(0, "unexpected call\n"); 387 return E_NOTIMPL; 388 } 389 390 static HRESULT WINAPI htmldoc2_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p) 391 { 392 ok(0, "unexpected call\n"); 393 return E_NOTIMPL; 394 } 395 396 static HRESULT WINAPI htmldoc2_put_bgColor(IHTMLDocument2 *iface, VARIANT v) 397 { 398 ok(0, "unexpected call\n"); 399 return E_NOTIMPL; 400 } 401 402 static HRESULT WINAPI htmldoc2_get_bgColor(IHTMLDocument2 *iface, VARIANT *p) 403 { 404 ok(0, "unexpected call\n"); 405 return E_NOTIMPL; 406 } 407 408 static HRESULT WINAPI htmldoc2_put_fgColor(IHTMLDocument2 *iface, VARIANT v) 409 { 410 ok(0, "unexpected call\n"); 411 return E_NOTIMPL; 412 } 413 414 static HRESULT WINAPI htmldoc2_get_fgColor(IHTMLDocument2 *iface, VARIANT *p) 415 { 416 ok(0, "unexpected call\n"); 417 return E_NOTIMPL; 418 } 419 420 static HRESULT WINAPI htmldoc2_put_linkColor(IHTMLDocument2 *iface, VARIANT v) 421 { 422 ok(0, "unexpected call\n"); 423 return E_NOTIMPL; 424 } 425 426 static HRESULT WINAPI htmldoc2_get_linkColor(IHTMLDocument2 *iface, VARIANT *p) 427 { 428 ok(0, "unexpected call\n"); 429 return E_NOTIMPL; 430 } 431 432 static HRESULT WINAPI htmldoc2_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v) 433 { 434 ok(0, "unexpected call\n"); 435 return E_NOTIMPL; 436 } 437 438 static HRESULT WINAPI htmldoc2_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p) 439 { 440 ok(0, "unexpected call\n"); 441 return E_NOTIMPL; 442 } 443 444 static HRESULT WINAPI htmldoc2_get_referrer(IHTMLDocument2 *iface, BSTR *p) 445 { 446 ok(0, "unexpected call\n"); 447 return E_NOTIMPL; 448 } 449 450 static HRESULT WINAPI htmldoc2_get_location(IHTMLDocument2 *iface, IHTMLLocation **p) 451 { 452 ok(0, "unexpected call\n"); 453 return E_NOTIMPL; 454 } 455 456 static HRESULT WINAPI htmldoc2_get_lastModified(IHTMLDocument2 *iface, BSTR *p) 457 { 458 ok(0, "unexpected call\n"); 459 return E_NOTIMPL; 460 } 461 462 static HRESULT WINAPI htmldoc2_put_URL(IHTMLDocument2 *iface, BSTR v) 463 { 464 ok(0, "unexpected call\n"); 465 return E_NOTIMPL; 466 } 467 468 static HRESULT WINAPI htmldoc2_get_URL(IHTMLDocument2 *iface, BSTR *p) 469 { 470 CHECK_EXPECT2(htmldoc2_get_url); 471 *p = a2bstr("http://test.winehq.org/"); 472 return S_OK; 473 } 474 475 static HRESULT WINAPI htmldoc2_put_domain(IHTMLDocument2 *iface, BSTR v) 476 { 477 ok(0, "unexpected call\n"); 478 return E_NOTIMPL; 479 } 480 481 static HRESULT WINAPI htmldoc2_get_domain(IHTMLDocument2 *iface, BSTR *p) 482 { 483 ok(0, "unexpected call\n"); 484 return E_NOTIMPL; 485 } 486 487 static HRESULT WINAPI htmldoc2_put_cookie(IHTMLDocument2 *iface, BSTR v) 488 { 489 ok(0, "unexpected call\n"); 490 return E_NOTIMPL; 491 } 492 493 static HRESULT WINAPI htmldoc2_get_cookie(IHTMLDocument2 *iface, BSTR *p) 494 { 495 ok(0, "unexpected call\n"); 496 return E_NOTIMPL; 497 } 498 499 static HRESULT WINAPI htmldoc2_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v) 500 { 501 ok(0, "unexpected call\n"); 502 return E_NOTIMPL; 503 } 504 505 static HRESULT WINAPI htmldoc2_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p) 506 { 507 ok(0, "unexpected call\n"); 508 return E_NOTIMPL; 509 } 510 511 static HRESULT WINAPI htmldoc2_put_charset(IHTMLDocument2 *iface, BSTR v) 512 { 513 ok(0, "unexpected call\n"); 514 return E_NOTIMPL; 515 } 516 517 static HRESULT WINAPI htmldoc2_get_charset(IHTMLDocument2 *iface, BSTR *p) 518 { 519 ok(0, "unexpected call\n"); 520 return E_NOTIMPL; 521 } 522 523 static HRESULT WINAPI htmldoc2_put_defaultCharset(IHTMLDocument2 *iface, BSTR v) 524 { 525 ok(0, "unexpected call\n"); 526 return E_NOTIMPL; 527 } 528 529 static HRESULT WINAPI htmldoc2_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p) 530 { 531 ok(0, "unexpected call\n"); 532 return E_NOTIMPL; 533 } 534 535 static HRESULT WINAPI htmldoc2_get_mimeType(IHTMLDocument2 *iface, BSTR *p) 536 { 537 ok(0, "unexpected call\n"); 538 return E_NOTIMPL; 539 } 540 541 static HRESULT WINAPI htmldoc2_get_fileSize(IHTMLDocument2 *iface, BSTR *p) 542 { 543 ok(0, "unexpected call\n"); 544 return E_NOTIMPL; 545 } 546 547 static HRESULT WINAPI htmldoc2_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p) 548 { 549 ok(0, "unexpected call\n"); 550 return E_NOTIMPL; 551 } 552 553 static HRESULT WINAPI htmldoc2_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p) 554 { 555 ok(0, "unexpected call\n"); 556 return E_NOTIMPL; 557 } 558 559 static HRESULT WINAPI htmldoc2_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p) 560 { 561 ok(0, "unexpected call\n"); 562 return E_NOTIMPL; 563 } 564 565 static HRESULT WINAPI htmldoc2_get_security(IHTMLDocument2 *iface, BSTR *p) 566 { 567 ok(0, "unexpected call\n"); 568 return E_NOTIMPL; 569 } 570 571 static HRESULT WINAPI htmldoc2_get_protocol(IHTMLDocument2 *iface, BSTR *p) 572 { 573 ok(0, "unexpected call\n"); 574 return E_NOTIMPL; 575 } 576 577 static HRESULT WINAPI htmldoc2_get_nameProp(IHTMLDocument2 *iface, BSTR *p) 578 { 579 ok(0, "unexpected call\n"); 580 return E_NOTIMPL; 581 } 582 583 static HRESULT WINAPI htmldoc2_write(IHTMLDocument2 *iface, SAFEARRAY *psarray) 584 { 585 ok(0, "unexpected call\n"); 586 return E_NOTIMPL; 587 } 588 589 static HRESULT WINAPI htmldoc2_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray) 590 { 591 ok(0, "unexpected call\n"); 592 return E_NOTIMPL; 593 } 594 595 static HRESULT WINAPI htmldoc2_open(IHTMLDocument2 *iface, BSTR url, VARIANT name, 596 VARIANT features, VARIANT replace, IDispatch **pomWindowResult) 597 { 598 ok(0, "unexpected call\n"); 599 return E_NOTIMPL; 600 } 601 602 static HRESULT WINAPI htmldoc2_close(IHTMLDocument2 *iface) 603 { 604 ok(0, "unexpected call\n"); 605 return E_NOTIMPL; 606 } 607 608 static HRESULT WINAPI htmldoc2_clear(IHTMLDocument2 *iface) 609 { 610 ok(0, "unexpected call\n"); 611 return E_NOTIMPL; 612 } 613 614 static HRESULT WINAPI htmldoc2_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID, 615 VARIANT_BOOL *pfRet) 616 { 617 ok(0, "unexpected call\n"); 618 return E_NOTIMPL; 619 } 620 621 static HRESULT WINAPI htmldoc2_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID, 622 VARIANT_BOOL *pfRet) 623 { 624 ok(0, "unexpected call\n"); 625 return E_NOTIMPL; 626 } 627 628 static HRESULT WINAPI htmldoc2_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID, 629 VARIANT_BOOL *pfRet) 630 { 631 ok(0, "unexpected call\n"); 632 return E_NOTIMPL; 633 } 634 635 static HRESULT WINAPI htmldoc2_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID, 636 VARIANT_BOOL *pfRet) 637 { 638 ok(0, "unexpected call\n"); 639 return E_NOTIMPL; 640 } 641 642 static HRESULT WINAPI htmldoc2_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID, 643 BSTR *pfRet) 644 { 645 ok(0, "unexpected call\n"); 646 return E_NOTIMPL; 647 } 648 649 static HRESULT WINAPI htmldoc2_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID, 650 VARIANT *pfRet) 651 { 652 ok(0, "unexpected call\n"); 653 return E_NOTIMPL; 654 } 655 656 static HRESULT WINAPI htmldoc2_execCommand(IHTMLDocument2 *iface, BSTR cmdID, 657 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet) 658 { 659 ok(0, "unexpected call\n"); 660 return E_NOTIMPL; 661 } 662 663 static HRESULT WINAPI htmldoc2_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID, 664 VARIANT_BOOL *pfRet) 665 { 666 ok(0, "unexpected call\n"); 667 return E_NOTIMPL; 668 } 669 670 static HRESULT WINAPI htmldoc2_createElement(IHTMLDocument2 *iface, BSTR eTag, 671 IHTMLElement **newElem) 672 { 673 ok(0, "unexpected call\n"); 674 return E_NOTIMPL; 675 } 676 677 static HRESULT WINAPI htmldoc2_put_onhelp(IHTMLDocument2 *iface, VARIANT v) 678 { 679 ok(0, "unexpected call\n"); 680 return E_NOTIMPL; 681 } 682 683 static HRESULT WINAPI htmldoc2_get_onhelp(IHTMLDocument2 *iface, VARIANT *p) 684 { 685 ok(0, "unexpected call\n"); 686 return E_NOTIMPL; 687 } 688 689 static HRESULT WINAPI htmldoc2_put_onclick(IHTMLDocument2 *iface, VARIANT v) 690 { 691 ok(0, "unexpected call\n"); 692 return E_NOTIMPL; 693 } 694 695 static HRESULT WINAPI htmldoc2_get_onclick(IHTMLDocument2 *iface, VARIANT *p) 696 { 697 ok(0, "unexpected call\n"); 698 return E_NOTIMPL; 699 } 700 701 static HRESULT WINAPI htmldoc2_put_ondblclick(IHTMLDocument2 *iface, VARIANT v) 702 { 703 ok(0, "unexpected call\n"); 704 return E_NOTIMPL; 705 } 706 707 static HRESULT WINAPI htmldoc2_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p) 708 { 709 ok(0, "unexpected call\n"); 710 return E_NOTIMPL; 711 } 712 713 static HRESULT WINAPI htmldoc2_put_onkeyup(IHTMLDocument2 *iface, VARIANT v) 714 { 715 ok(0, "unexpected call\n"); 716 return E_NOTIMPL; 717 } 718 719 static HRESULT WINAPI htmldoc2_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p) 720 { 721 ok(0, "unexpected call\n"); 722 return E_NOTIMPL; 723 } 724 725 static HRESULT WINAPI htmldoc2_put_onkeydown(IHTMLDocument2 *iface, VARIANT v) 726 { 727 ok(0, "unexpected call\n"); 728 return E_NOTIMPL; 729 } 730 731 static HRESULT WINAPI htmldoc2_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p) 732 { 733 ok(0, "unexpected call\n"); 734 return E_NOTIMPL; 735 } 736 737 static HRESULT WINAPI htmldoc2_put_onkeypress(IHTMLDocument2 *iface, VARIANT v) 738 { 739 ok(0, "unexpected call\n"); 740 return E_NOTIMPL; 741 } 742 743 static HRESULT WINAPI htmldoc2_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p) 744 { 745 ok(0, "unexpected call\n"); 746 return E_NOTIMPL; 747 } 748 749 static HRESULT WINAPI htmldoc2_put_onmouseup(IHTMLDocument2 *iface, VARIANT v) 750 { 751 ok(0, "unexpected call\n"); 752 return E_NOTIMPL; 753 } 754 755 static HRESULT WINAPI htmldoc2_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p) 756 { 757 ok(0, "unexpected call\n"); 758 return E_NOTIMPL; 759 } 760 761 static HRESULT WINAPI htmldoc2_put_onmousedown(IHTMLDocument2 *iface, VARIANT v) 762 { 763 ok(0, "unexpected call\n"); 764 return E_NOTIMPL; 765 } 766 767 static HRESULT WINAPI htmldoc2_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p) 768 { 769 ok(0, "unexpected call\n"); 770 return E_NOTIMPL; 771 } 772 773 static HRESULT WINAPI htmldoc2_put_onmousemove(IHTMLDocument2 *iface, VARIANT v) 774 { 775 ok(0, "unexpected call\n"); 776 return E_NOTIMPL; 777 } 778 779 static HRESULT WINAPI htmldoc2_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p) 780 { 781 ok(0, "unexpected call\n"); 782 return E_NOTIMPL; 783 } 784 785 static HRESULT WINAPI htmldoc2_put_onmouseout(IHTMLDocument2 *iface, VARIANT v) 786 { 787 ok(0, "unexpected call\n"); 788 return E_NOTIMPL; 789 } 790 791 static HRESULT WINAPI htmldoc2_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p) 792 { 793 ok(0, "unexpected call\n"); 794 return E_NOTIMPL; 795 } 796 797 static HRESULT WINAPI htmldoc2_put_onmouseover(IHTMLDocument2 *iface, VARIANT v) 798 { 799 ok(0, "unexpected call\n"); 800 return E_NOTIMPL; 801 } 802 803 static HRESULT WINAPI htmldoc2_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p) 804 { 805 ok(0, "unexpected call\n"); 806 return E_NOTIMPL; 807 } 808 809 static HRESULT WINAPI htmldoc2_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v) 810 { 811 ok(0, "unexpected call\n"); 812 return E_NOTIMPL; 813 } 814 815 static HRESULT WINAPI htmldoc2_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p) 816 { 817 ok(0, "unexpected call\n"); 818 return E_NOTIMPL; 819 } 820 821 static HRESULT WINAPI htmldoc2_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v) 822 { 823 ok(0, "unexpected call\n"); 824 return E_NOTIMPL; 825 } 826 827 static HRESULT WINAPI htmldoc2_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p) 828 { 829 ok(0, "unexpected call\n"); 830 return E_NOTIMPL; 831 } 832 833 static HRESULT WINAPI htmldoc2_put_onrowexit(IHTMLDocument2 *iface, VARIANT v) 834 { 835 ok(0, "unexpected call\n"); 836 return E_NOTIMPL; 837 } 838 839 static HRESULT WINAPI htmldoc2_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p) 840 { 841 ok(0, "unexpected call\n"); 842 return E_NOTIMPL; 843 } 844 845 static HRESULT WINAPI htmldoc2_put_onrowenter(IHTMLDocument2 *iface, VARIANT v) 846 { 847 ok(0, "unexpected call\n"); 848 return E_NOTIMPL; 849 } 850 851 static HRESULT WINAPI htmldoc2_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p) 852 { 853 ok(0, "unexpected call\n"); 854 return E_NOTIMPL; 855 } 856 857 static HRESULT WINAPI htmldoc2_put_ondragstart(IHTMLDocument2 *iface, VARIANT v) 858 { 859 ok(0, "unexpected call\n"); 860 return E_NOTIMPL; 861 } 862 863 static HRESULT WINAPI htmldoc2_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p) 864 { 865 ok(0, "unexpected call\n"); 866 return E_NOTIMPL; 867 } 868 869 static HRESULT WINAPI htmldoc2_put_onselectstart(IHTMLDocument2 *iface, VARIANT v) 870 { 871 ok(0, "unexpected call\n"); 872 return E_NOTIMPL; 873 } 874 875 static HRESULT WINAPI htmldoc2_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p) 876 { 877 ok(0, "unexpected call\n"); 878 return E_NOTIMPL; 879 } 880 881 static HRESULT WINAPI htmldoc2_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y, 882 IHTMLElement **elementHit) 883 { 884 ok(0, "unexpected call\n"); 885 return E_NOTIMPL; 886 } 887 888 static HRESULT WINAPI htmldoc2_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p) 889 { 890 ok(0, "unexpected call\n"); 891 return E_NOTIMPL; 892 } 893 894 static HRESULT WINAPI htmldoc2_get_styleSheets(IHTMLDocument2 *iface, 895 IHTMLStyleSheetsCollection **p) 896 { 897 ok(0, "unexpected call\n"); 898 return E_NOTIMPL; 899 } 900 901 static HRESULT WINAPI htmldoc2_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v) 902 { 903 ok(0, "unexpected call\n"); 904 return E_NOTIMPL; 905 } 906 907 static HRESULT WINAPI htmldoc2_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p) 908 { 909 ok(0, "unexpected call\n"); 910 return E_NOTIMPL; 911 } 912 913 static HRESULT WINAPI htmldoc2_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v) 914 { 915 ok(0, "unexpected call\n"); 916 return E_NOTIMPL; 917 } 918 919 static HRESULT WINAPI htmldoc2_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p) 920 { 921 ok(0, "unexpected call\n"); 922 return E_NOTIMPL; 923 } 924 925 static HRESULT WINAPI htmldoc2_toString(IHTMLDocument2 *iface, BSTR *String) 926 { 927 ok(0, "unexpected call\n"); 928 return E_NOTIMPL; 929 } 930 931 static HRESULT WINAPI htmldoc2_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref, 932 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet) 933 { 934 ok(0, "unexpected call\n"); 935 return E_NOTIMPL; 936 } 937 938 static const IHTMLDocument2Vtbl TestHTMLDocumentVtbl = { 939 htmldoc2_QueryInterface, 940 htmldoc2_AddRef, 941 htmldoc2_Release, 942 htmldoc2_GetTypeInfoCount, 943 htmldoc2_GetTypeInfo, 944 htmldoc2_GetIDsOfNames, 945 htmldoc2_Invoke, 946 htmldoc2_get_Script, 947 htmldoc2_get_all, 948 htmldoc2_get_body, 949 htmldoc2_get_activeElement, 950 htmldoc2_get_images, 951 htmldoc2_get_applets, 952 htmldoc2_get_links, 953 htmldoc2_get_forms, 954 htmldoc2_get_anchors, 955 htmldoc2_put_title, 956 htmldoc2_get_title, 957 htmldoc2_get_scripts, 958 htmldoc2_put_designMode, 959 htmldoc2_get_designMode, 960 htmldoc2_get_selection, 961 htmldoc2_get_readyState, 962 htmldoc2_get_frames, 963 htmldoc2_get_embeds, 964 htmldoc2_get_plugins, 965 htmldoc2_put_alinkColor, 966 htmldoc2_get_alinkColor, 967 htmldoc2_put_bgColor, 968 htmldoc2_get_bgColor, 969 htmldoc2_put_fgColor, 970 htmldoc2_get_fgColor, 971 htmldoc2_put_linkColor, 972 htmldoc2_get_linkColor, 973 htmldoc2_put_vlinkColor, 974 htmldoc2_get_vlinkColor, 975 htmldoc2_get_referrer, 976 htmldoc2_get_location, 977 htmldoc2_get_lastModified, 978 htmldoc2_put_URL, 979 htmldoc2_get_URL, 980 htmldoc2_put_domain, 981 htmldoc2_get_domain, 982 htmldoc2_put_cookie, 983 htmldoc2_get_cookie, 984 htmldoc2_put_expando, 985 htmldoc2_get_expando, 986 htmldoc2_put_charset, 987 htmldoc2_get_charset, 988 htmldoc2_put_defaultCharset, 989 htmldoc2_get_defaultCharset, 990 htmldoc2_get_mimeType, 991 htmldoc2_get_fileSize, 992 htmldoc2_get_fileCreatedDate, 993 htmldoc2_get_fileModifiedDate, 994 htmldoc2_get_fileUpdatedDate, 995 htmldoc2_get_security, 996 htmldoc2_get_protocol, 997 htmldoc2_get_nameProp, 998 htmldoc2_write, 999 htmldoc2_writeln, 1000 htmldoc2_open, 1001 htmldoc2_close, 1002 htmldoc2_clear, 1003 htmldoc2_queryCommandSupported, 1004 htmldoc2_queryCommandEnabled, 1005 htmldoc2_queryCommandState, 1006 htmldoc2_queryCommandIndeterm, 1007 htmldoc2_queryCommandText, 1008 htmldoc2_queryCommandValue, 1009 htmldoc2_execCommand, 1010 htmldoc2_execCommandShowHelp, 1011 htmldoc2_createElement, 1012 htmldoc2_put_onhelp, 1013 htmldoc2_get_onhelp, 1014 htmldoc2_put_onclick, 1015 htmldoc2_get_onclick, 1016 htmldoc2_put_ondblclick, 1017 htmldoc2_get_ondblclick, 1018 htmldoc2_put_onkeyup, 1019 htmldoc2_get_onkeyup, 1020 htmldoc2_put_onkeydown, 1021 htmldoc2_get_onkeydown, 1022 htmldoc2_put_onkeypress, 1023 htmldoc2_get_onkeypress, 1024 htmldoc2_put_onmouseup, 1025 htmldoc2_get_onmouseup, 1026 htmldoc2_put_onmousedown, 1027 htmldoc2_get_onmousedown, 1028 htmldoc2_put_onmousemove, 1029 htmldoc2_get_onmousemove, 1030 htmldoc2_put_onmouseout, 1031 htmldoc2_get_onmouseout, 1032 htmldoc2_put_onmouseover, 1033 htmldoc2_get_onmouseover, 1034 htmldoc2_put_onreadystatechange, 1035 htmldoc2_get_onreadystatechange, 1036 htmldoc2_put_onafterupdate, 1037 htmldoc2_get_onafterupdate, 1038 htmldoc2_put_onrowexit, 1039 htmldoc2_get_onrowexit, 1040 htmldoc2_put_onrowenter, 1041 htmldoc2_get_onrowenter, 1042 htmldoc2_put_ondragstart, 1043 htmldoc2_get_ondragstart, 1044 htmldoc2_put_onselectstart, 1045 htmldoc2_get_onselectstart, 1046 htmldoc2_elementFromPoint, 1047 htmldoc2_get_parentWindow, 1048 htmldoc2_get_styleSheets, 1049 htmldoc2_put_onbeforeupdate, 1050 htmldoc2_get_onbeforeupdate, 1051 htmldoc2_put_onerrorupdate, 1052 htmldoc2_get_onerrorupdate, 1053 htmldoc2_toString, 1054 htmldoc2_createStyleSheet 1055 }; 1056 1057 static IHTMLDocument2 htmldoc2 = { &TestHTMLDocumentVtbl }; 1058 1059 static HRESULT WINAPI sp_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppvObject) 1060 { 1061 *ppvObject = NULL; 1062 1063 if (IsEqualGUID(riid, &IID_IUnknown) || 1064 IsEqualGUID(riid, &IID_IServiceProvider)) 1065 { 1066 *ppvObject = iface; 1067 IServiceProvider_AddRef(iface); 1068 return S_OK; 1069 } 1070 1071 ok(0, "unexpected query interface: %s\n", wine_dbgstr_guid(riid)); 1072 1073 return E_NOINTERFACE; 1074 } 1075 1076 static ULONG WINAPI sp_AddRef(IServiceProvider *iface) 1077 { 1078 return 2; 1079 } 1080 1081 static ULONG WINAPI sp_Release(IServiceProvider *iface) 1082 { 1083 return 1; 1084 } 1085 1086 static HRESULT WINAPI sp_QueryService(IServiceProvider *iface, REFGUID service, REFIID riid, void **obj) 1087 { 1088 *obj = NULL; 1089 1090 if (IsEqualGUID(service, &SID_SBindHost) && 1091 IsEqualGUID(riid, &IID_IBindHost)) 1092 { 1093 CHECK_EXPECT2(sp_queryservice_SID_SBindHost); 1094 } 1095 else if (IsEqualGUID(service, &SID_SContainerDispatch) && 1096 IsEqualGUID(riid, &IID_IHTMLDocument2)) 1097 { 1098 CHECK_EXPECT2(sp_queryservice_SID_SContainerDispatch_htmldoc2); 1099 } 1100 else if (IsEqualGUID(service, &SID_SInternetHostSecurityManager) && 1101 IsEqualGUID(riid, &IID_IHTMLDocument2)) 1102 { 1103 CHECK_EXPECT2(sp_queryservice_SID_secmgr_htmldoc2); 1104 *obj = &htmldoc2; 1105 return S_OK; 1106 } 1107 else if (IsEqualGUID(service, &SID_SInternetHostSecurityManager) && 1108 IsEqualGUID(riid, &IID_IXMLDOMDocument)) 1109 { 1110 CHECK_EXPECT2(sp_queryservice_SID_secmgr_xmldomdoc); 1111 } 1112 else if (IsEqualGUID(service, &SID_SInternetHostSecurityManager) && 1113 IsEqualGUID(riid, &IID_IInternetHostSecurityManager)) 1114 { 1115 CHECK_EXPECT2(sp_queryservice_SID_secmgr_secmgr); 1116 } 1117 else if (IsEqualGUID(service, &SID_UnknownSID) && 1118 IsEqualGUID(riid, &IID_IStream)) 1119 { 1120 /* FIXME: unidentified service id */ 1121 } 1122 else if ((IsEqualGUID(service, &IID_IInternetProtocol) && IsEqualGUID(riid, &IID_IInternetProtocol)) || 1123 (IsEqualGUID(service, &IID_IHttpNegotiate2) && IsEqualGUID(riid, &IID_IHttpNegotiate2)) || 1124 (IsEqualGUID(service, &IID_IGetBindHandle) && IsEqualGUID(riid, &IID_IGetBindHandle)) || 1125 (IsEqualGUID(service, &IID_IBindStatusCallback) && IsEqualGUID(riid, &IID_IBindStatusCallback)) || 1126 (IsEqualGUID(service, &IID_IWindowForBindingUI) && IsEqualGUID(riid, &IID_IWindowForBindingUI))) 1127 { 1128 } 1129 else 1130 ok(0, "unexpected request: sid %s, riid %s\n", wine_dbgstr_guid(service), wine_dbgstr_guid(riid)); 1131 1132 return E_NOTIMPL; 1133 } 1134 1135 static const IServiceProviderVtbl testprovVtbl = 1136 { 1137 sp_QueryInterface, 1138 sp_AddRef, 1139 sp_Release, 1140 sp_QueryService 1141 }; 1142 1143 static IServiceProvider testprov = { &testprovVtbl }; 1144 1145 static HRESULT WINAPI site_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject) 1146 { 1147 *ppvObject = NULL; 1148 1149 if (IsEqualGUID(riid, &IID_IServiceProvider)) 1150 CHECK_EXPECT2(site_qi_IServiceProvider); 1151 1152 if (IsEqualGUID(riid, &IID_IXMLDOMDocument)) 1153 CHECK_EXPECT2(site_qi_IXMLDOMDocument); 1154 1155 if (IsEqualGUID(riid, &IID_IOleClientSite)) 1156 CHECK_EXPECT2(site_qi_IOleClientSite); 1157 1158 if (IsEqualGUID(riid, &IID_IUnknown)) 1159 *ppvObject = iface; 1160 else if (IsEqualGUID(riid, &IID_IServiceProvider)) 1161 *ppvObject = &testprov; 1162 1163 if (*ppvObject) IUnknown_AddRef(iface); 1164 1165 return *ppvObject ? S_OK : E_NOINTERFACE; 1166 } 1167 1168 static ULONG WINAPI site_AddRef(IUnknown *iface) 1169 { 1170 return 2; 1171 } 1172 1173 static ULONG WINAPI site_Release(IUnknown *iface) 1174 { 1175 return 1; 1176 } 1177 1178 static const IUnknownVtbl testsiteVtbl = 1179 { 1180 site_QueryInterface, 1181 site_AddRef, 1182 site_Release 1183 }; 1184 1185 static IUnknown testsite = { &testsiteVtbl }; 1186 1187 typedef struct 1188 { 1189 IDispatch IDispatch_iface; 1190 LONG ref; 1191 } dispevent; 1192 1193 static IXMLHttpRequest *httpreq; 1194 1195 static inline dispevent *impl_from_IDispatch( IDispatch *iface ) 1196 { 1197 return CONTAINING_RECORD(iface, dispevent, IDispatch_iface); 1198 } 1199 1200 static HRESULT WINAPI dispevent_QueryInterface(IDispatch *iface, REFIID riid, void **ppvObject) 1201 { 1202 *ppvObject = NULL; 1203 1204 if ( IsEqualGUID( riid, &IID_IDispatch) || 1205 IsEqualGUID( riid, &IID_IUnknown) ) 1206 { 1207 *ppvObject = iface; 1208 } 1209 else 1210 return E_NOINTERFACE; 1211 1212 IDispatch_AddRef( iface ); 1213 1214 return S_OK; 1215 } 1216 1217 static ULONG WINAPI dispevent_AddRef(IDispatch *iface) 1218 { 1219 dispevent *This = impl_from_IDispatch( iface ); 1220 return InterlockedIncrement( &This->ref ); 1221 } 1222 1223 static ULONG WINAPI dispevent_Release(IDispatch *iface) 1224 { 1225 dispevent *This = impl_from_IDispatch( iface ); 1226 ULONG ref = InterlockedDecrement( &This->ref ); 1227 1228 if (ref == 0) 1229 HeapFree(GetProcessHeap(), 0, This); 1230 1231 return ref; 1232 } 1233 1234 static HRESULT WINAPI dispevent_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo) 1235 { 1236 g_unexpectedcall++; 1237 *pctinfo = 0; 1238 return S_OK; 1239 } 1240 1241 static HRESULT WINAPI dispevent_GetTypeInfo(IDispatch *iface, UINT iTInfo, 1242 LCID lcid, ITypeInfo **ppTInfo) 1243 { 1244 g_unexpectedcall++; 1245 return S_OK; 1246 } 1247 1248 static HRESULT WINAPI dispevent_GetIDsOfNames(IDispatch *iface, REFIID riid, 1249 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) 1250 { 1251 g_unexpectedcall++; 1252 return S_OK; 1253 } 1254 1255 static HRESULT WINAPI dispevent_Invoke(IDispatch *iface, DISPID member, REFIID riid, 1256 LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, 1257 EXCEPINFO *excepInfo, UINT *argErr) 1258 { 1259 LONG state; 1260 HRESULT hr; 1261 1262 ok(member == 0, "expected 0 member, got %d\n", member); 1263 ok(lcid == LOCALE_SYSTEM_DEFAULT, "expected LOCALE_SYSTEM_DEFAULT, got lcid %x\n", lcid); 1264 ok(flags == DISPATCH_METHOD, "expected DISPATCH_METHOD, got %d\n", flags); 1265 1266 ok(params->cArgs == 0, "got %d\n", params->cArgs); 1267 ok(params->cNamedArgs == 0, "got %d\n", params->cNamedArgs); 1268 ok(params->rgvarg == NULL, "got %p\n", params->rgvarg); 1269 ok(params->rgdispidNamedArgs == NULL, "got %p\n", params->rgdispidNamedArgs); 1270 1271 ok(result == NULL, "got %p\n", result); 1272 ok(excepInfo == NULL, "got %p\n", excepInfo); 1273 ok(argErr == NULL, "got %p\n", argErr); 1274 1275 g_expectedcall++; 1276 1277 state = READYSTATE_UNINITIALIZED; 1278 hr = IXMLHttpRequest_get_readyState(httpreq, &state); 1279 ok(hr == S_OK, "got 0x%08x\n", hr); 1280 if (state == READYSTATE_COMPLETE) 1281 { 1282 BSTR text = NULL; 1283 1284 hr = IXMLHttpRequest_get_responseText(httpreq, &text); 1285 ok(hr == S_OK, "got 0x%08x\n", hr); 1286 ok(*text != 0, "got %s\n", wine_dbgstr_w(text)); 1287 SysFreeString(text); 1288 } 1289 1290 return E_FAIL; 1291 } 1292 1293 static const IDispatchVtbl dispeventVtbl = 1294 { 1295 dispevent_QueryInterface, 1296 dispevent_AddRef, 1297 dispevent_Release, 1298 dispevent_GetTypeInfoCount, 1299 dispevent_GetTypeInfo, 1300 dispevent_GetIDsOfNames, 1301 dispevent_Invoke 1302 }; 1303 1304 static IDispatch* create_dispevent(void) 1305 { 1306 dispevent *event = HeapAlloc(GetProcessHeap(), 0, sizeof(*event)); 1307 1308 event->IDispatch_iface.lpVtbl = &dispeventVtbl; 1309 event->ref = 1; 1310 1311 return &event->IDispatch_iface; 1312 } 1313 1314 static IXMLHttpRequest *create_xhr(void) 1315 { 1316 IXMLHttpRequest *ret; 1317 HRESULT hr; 1318 1319 hr = CoCreateInstance(&CLSID_XMLHTTPRequest, NULL, CLSCTX_INPROC_SERVER, 1320 &IID_IXMLHttpRequest, (void**)&ret); 1321 1322 return SUCCEEDED(hr) ? ret : NULL; 1323 } 1324 1325 static IServerXMLHTTPRequest *create_server_xhr(void) 1326 { 1327 IServerXMLHTTPRequest *ret; 1328 HRESULT hr; 1329 1330 hr = CoCreateInstance(&CLSID_ServerXMLHTTP30, NULL, CLSCTX_INPROC_SERVER, &IID_IServerXMLHTTPRequest, (void **)&ret); 1331 1332 return SUCCEEDED(hr) ? ret : NULL; 1333 } 1334 1335 static void set_safety_opt(IUnknown *unk, DWORD mask, DWORD opts) 1336 { 1337 IObjectSafety *obj_safety; 1338 HRESULT hr; 1339 1340 hr = IUnknown_QueryInterface(unk, &IID_IObjectSafety, (void**)&obj_safety); 1341 ok(hr == S_OK, "Could not get IObjectSafety iface: %08x\n", hr); 1342 1343 hr = IObjectSafety_SetInterfaceSafetyOptions(obj_safety, &IID_IDispatch, mask, mask&opts); 1344 ok(hr == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hr); 1345 1346 IObjectSafety_Release(obj_safety); 1347 } 1348 1349 static void set_xhr_site(IXMLHttpRequest *xhr) 1350 { 1351 IObjectWithSite *obj_site; 1352 HRESULT hr; 1353 1354 hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site); 1355 ok(hr == S_OK, "Could not get IObjectWithSite iface: %08x\n", hr); 1356 1357 g_enablecallchecks = TRUE; 1358 1359 SET_EXPECT(site_qi_IServiceProvider); 1360 SET_EXPECT(sp_queryservice_SID_SBindHost); 1361 SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2); 1362 SET_EXPECT(sp_queryservice_SID_secmgr_htmldoc2); 1363 SET_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc); 1364 SET_EXPECT(sp_queryservice_SID_secmgr_secmgr); 1365 1366 /* calls to IHTMLDocument2 */ 1367 SET_EXPECT(htmldoc2_get_all); 1368 SET_EXPECT(collection_get_length); 1369 SET_EXPECT(htmldoc2_get_url); 1370 1371 SET_EXPECT(site_qi_IXMLDOMDocument); 1372 SET_EXPECT(site_qi_IOleClientSite); 1373 1374 hr = IObjectWithSite_SetSite(obj_site, &testsite); 1375 EXPECT_HR(hr, S_OK); 1376 1377 CHECK_CALLED(site_qi_IServiceProvider); 1378 todo_wine 1379 CHECK_CALLED(sp_queryservice_SID_SBindHost); 1380 CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2); 1381 CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2); 1382 todo_wine 1383 CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc); 1384 /* this one isn't very reliable 1385 CHECK_CALLED(sp_queryservice_SID_secmgr_secmgr); */ 1386 todo_wine { 1387 CHECK_CALLED(htmldoc2_get_all); 1388 CHECK_CALLED(collection_get_length); 1389 } 1390 CHECK_CALLED(htmldoc2_get_url); 1391 1392 todo_wine { 1393 CHECK_CALLED(site_qi_IXMLDOMDocument); 1394 CHECK_CALLED(site_qi_IOleClientSite); 1395 } 1396 1397 g_enablecallchecks = FALSE; 1398 1399 IObjectWithSite_Release(obj_site); 1400 } 1401 1402 #define test_open(a,b,c,d) _test_open(__LINE__,a,b,c,d) 1403 static void _test_open(unsigned line, IXMLHttpRequest *xhr, const char *method, const char *url, HRESULT exhres) 1404 { 1405 VARIANT empty, vfalse; 1406 HRESULT hr; 1407 1408 V_VT(&empty) = VT_EMPTY; 1409 V_VT(&vfalse) = VT_BOOL; 1410 V_BOOL(&vfalse) = VARIANT_FALSE; 1411 1412 hr = IXMLHttpRequest_open(xhr, _bstr_(method), _bstr_(url), vfalse, empty, empty); 1413 ok_(__FILE__,line)(hr == exhres, "open(%s %s) failed: %08x, expected %08x\n", method, url, hr, exhres); 1414 } 1415 1416 static void test_XMLHTTP(void) 1417 { 1418 static const char bodyA[] = "mode=Test"; 1419 static const char urlA[] = "http://test.winehq.org/tests/post.php"; 1420 static const char xmltestA[] = "http://test.winehq.org/tests/xmltest.xml"; 1421 static const char referertesturl[] = "http://test.winehq.org/tests/referer.php"; 1422 static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0}; 1423 static const CHAR xmltestbodyA[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n"; 1424 static const WCHAR norefererW[] = {'n','o',' ','r','e','f','e','r','e','r',' ','s','e','t',0}; 1425 1426 IXMLHttpRequest *xhr; 1427 IObjectWithSite *obj_site, *obj_site2; 1428 BSTR bstrResponse, str, str1; 1429 VARIANT varbody; 1430 VARIANT dummy; 1431 LONG state, status, bound; 1432 IDispatch *event; 1433 void *ptr; 1434 HRESULT hr; 1435 HGLOBAL g; 1436 1437 xhr = create_xhr(); 1438 1439 VariantInit(&dummy); 1440 V_VT(&dummy) = VT_ERROR; 1441 V_ERROR(&dummy) = DISP_E_MEMBERNOTFOUND; 1442 1443 hr = IXMLHttpRequest_put_onreadystatechange(xhr, NULL); 1444 EXPECT_HR(hr, S_OK); 1445 1446 hr = IXMLHttpRequest_abort(xhr); 1447 EXPECT_HR(hr, S_OK); 1448 1449 V_VT(&varbody) = VT_I2; 1450 V_I2(&varbody) = 1; 1451 hr = IXMLHttpRequest_get_responseBody(xhr, &varbody); 1452 EXPECT_HR(hr, E_PENDING); 1453 ok(V_VT(&varbody) == VT_EMPTY, "got type %d\n", V_VT(&varbody)); 1454 1455 V_VT(&varbody) = VT_I2; 1456 V_I2(&varbody) = 1; 1457 hr = IXMLHttpRequest_get_responseStream(xhr, &varbody); 1458 EXPECT_HR(hr, E_PENDING); 1459 ok(V_VT(&varbody) == VT_EMPTY, "got type %d\n", V_VT(&varbody)); 1460 1461 /* send before open */ 1462 hr = IXMLHttpRequest_send(xhr, dummy); 1463 ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); 1464 1465 /* initial status code */ 1466 hr = IXMLHttpRequest_get_status(xhr, NULL); 1467 ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); 1468 1469 status = 0xdeadbeef; 1470 hr = IXMLHttpRequest_get_status(xhr, &status); 1471 ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); 1472 ok(status == READYSTATE_UNINITIALIZED || broken(status == 0xdeadbeef) /* <win8 */, "got %d\n", status); 1473 1474 hr = IXMLHttpRequest_get_statusText(xhr, &str); 1475 ok(hr == E_FAIL, "got 0x%08x\n", hr); 1476 1477 /* invalid parameters */ 1478 test_open(xhr, NULL, NULL, E_INVALIDARG); 1479 test_open(xhr, "POST", NULL, E_INVALIDARG); 1480 test_open(xhr, NULL, urlA, E_INVALIDARG); 1481 1482 hr = IXMLHttpRequest_setRequestHeader(xhr, NULL, NULL); 1483 EXPECT_HR(hr, E_INVALIDARG); 1484 1485 hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_("header1"), NULL); 1486 ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); 1487 1488 hr = IXMLHttpRequest_setRequestHeader(xhr, NULL, _bstr_("value1")); 1489 EXPECT_HR(hr, E_INVALIDARG); 1490 1491 hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_("header1"), _bstr_("value1")); 1492 ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); 1493 1494 hr = IXMLHttpRequest_get_readyState(xhr, NULL); 1495 ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); 1496 1497 state = -1; 1498 hr = IXMLHttpRequest_get_readyState(xhr, &state); 1499 EXPECT_HR(hr, S_OK); 1500 ok(state == READYSTATE_UNINITIALIZED, "got %d, expected READYSTATE_UNINITIALIZED\n", state); 1501 1502 httpreq = xhr; 1503 event = create_dispevent(); 1504 1505 EXPECT_REF(event, 1); 1506 hr = IXMLHttpRequest_put_onreadystatechange(xhr, event); 1507 EXPECT_HR(hr, S_OK); 1508 EXPECT_REF(event, 2); 1509 1510 g_unexpectedcall = g_expectedcall = 0; 1511 1512 test_open(xhr, "POST", urlA, S_OK); 1513 1514 ok(g_unexpectedcall == 0, "unexpected disp event call\n"); 1515 ok(g_expectedcall == 1 || broken(g_expectedcall == 0) /* win2k */, "no expected disp event call\n"); 1516 1517 /* status code after ::open() */ 1518 status = 0xdeadbeef; 1519 hr = IXMLHttpRequest_get_status(xhr, &status); 1520 ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); 1521 ok(status == READYSTATE_UNINITIALIZED || broken(status == 0xdeadbeef) /* <win8 */, "got %d\n", status); 1522 1523 state = -1; 1524 hr = IXMLHttpRequest_get_readyState(xhr, &state); 1525 EXPECT_HR(hr, S_OK); 1526 ok(state == READYSTATE_LOADING, "got %d, expected READYSTATE_LOADING\n", state); 1527 1528 hr = IXMLHttpRequest_abort(xhr); 1529 EXPECT_HR(hr, S_OK); 1530 1531 state = -1; 1532 hr = IXMLHttpRequest_get_readyState(xhr, &state); 1533 EXPECT_HR(hr, S_OK); 1534 ok(state == READYSTATE_UNINITIALIZED || broken(state == READYSTATE_LOADING) /* win2k */, 1535 "got %d, expected READYSTATE_UNINITIALIZED\n", state); 1536 1537 test_open(xhr, "POST", urlA, S_OK); 1538 1539 hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_("header1"), _bstr_("value1")); 1540 EXPECT_HR(hr, S_OK); 1541 1542 hr = IXMLHttpRequest_setRequestHeader(xhr, NULL, _bstr_("value1")); 1543 EXPECT_HR(hr, E_INVALIDARG); 1544 1545 hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_(""), _bstr_("value1")); 1546 EXPECT_HR(hr, E_INVALIDARG); 1547 1548 V_VT(&varbody) = VT_BSTR; 1549 V_BSTR(&varbody) = _bstr_(bodyA); 1550 1551 hr = IXMLHttpRequest_send(xhr, varbody); 1552 if (hr == INET_E_RESOURCE_NOT_FOUND) 1553 { 1554 skip("No connection could be made with test.winehq.org\n"); 1555 IXMLHttpRequest_Release(xhr); 1556 return; 1557 } 1558 EXPECT_HR(hr, S_OK); 1559 1560 /* response headers */ 1561 hr = IXMLHttpRequest_getAllResponseHeaders(xhr, NULL); 1562 ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); 1563 hr = IXMLHttpRequest_getAllResponseHeaders(xhr, &str); 1564 EXPECT_HR(hr, S_OK); 1565 /* status line is stripped already */ 1566 ok(memcmp(str, _bstr_("HTTP"), 4*sizeof(WCHAR)), "got response headers %s\n", wine_dbgstr_w(str)); 1567 ok(*str, "got empty headers\n"); 1568 hr = IXMLHttpRequest_getAllResponseHeaders(xhr, &str1); 1569 EXPECT_HR(hr, S_OK); 1570 ok(str1 != str, "got %p\n", str1); 1571 SysFreeString(str1); 1572 SysFreeString(str); 1573 1574 hr = IXMLHttpRequest_getResponseHeader(xhr, NULL, NULL); 1575 EXPECT_HR(hr, E_INVALIDARG); 1576 hr = IXMLHttpRequest_getResponseHeader(xhr, _bstr_("Date"), NULL); 1577 ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); 1578 hr = IXMLHttpRequest_getResponseHeader(xhr, _bstr_("Date"), &str); 1579 EXPECT_HR(hr, S_OK); 1580 ok(*str != ' ', "got leading space in header %s\n", wine_dbgstr_w(str)); 1581 SysFreeString(str); 1582 1583 /* status code after ::send() */ 1584 status = 0xdeadbeef; 1585 hr = IXMLHttpRequest_get_status(xhr, &status); 1586 EXPECT_HR(hr, S_OK); 1587 ok(status == 200, "got %d\n", status); 1588 1589 hr = IXMLHttpRequest_get_statusText(xhr, NULL); 1590 ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); 1591 1592 hr = IXMLHttpRequest_get_statusText(xhr, &str); 1593 EXPECT_HR(hr, S_OK); 1594 ok(!lstrcmpW(str, _bstr_("OK")), "got status %s\n", wine_dbgstr_w(str)); 1595 SysFreeString(str); 1596 1597 /* another ::send() after completed request */ 1598 V_VT(&varbody) = VT_BSTR; 1599 V_BSTR(&varbody) = _bstr_(bodyA); 1600 1601 hr = IXMLHttpRequest_send(xhr, varbody); 1602 ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); 1603 1604 hr = IXMLHttpRequest_get_responseText(xhr, &bstrResponse); 1605 EXPECT_HR(hr, S_OK); 1606 /* the server currently returns "FAILED" because the Content-Type header is 1607 * not what the server expects */ 1608 if(hr == S_OK) 1609 { 1610 ok(!memcmp(bstrResponse, wszExpectedResponse, sizeof(wszExpectedResponse)), 1611 "expected %s, got %s\n", wine_dbgstr_w(wszExpectedResponse), wine_dbgstr_w(bstrResponse)); 1612 SysFreeString(bstrResponse); 1613 } 1614 1615 /* POST: VT_VARIANT body */ 1616 /* VT_VARIANT|VT_BYREF fails on Windows 10 */ 1617 test_open(xhr, "POST", urlA, S_OK); 1618 1619 hr = IXMLHttpRequest_send(xhr, varbody); 1620 EXPECT_HR(hr, S_OK); 1621 1622 /* GET request */ 1623 test_open(xhr, "GET", xmltestA, S_OK); 1624 1625 V_VT(&varbody) = VT_EMPTY; 1626 1627 hr = IXMLHttpRequest_send(xhr, varbody); 1628 if (hr == INET_E_RESOURCE_NOT_FOUND) 1629 { 1630 skip("No connection could be made with test.winehq.org\n"); 1631 IXMLHttpRequest_Release(xhr); 1632 return; 1633 } 1634 EXPECT_HR(hr, S_OK); 1635 1636 hr = IXMLHttpRequest_get_responseText(xhr, NULL); 1637 ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); 1638 1639 hr = IXMLHttpRequest_get_responseText(xhr, &bstrResponse); 1640 EXPECT_HR(hr, S_OK); 1641 ok(!memcmp(bstrResponse, _bstr_(xmltestbodyA), sizeof(xmltestbodyA)*sizeof(WCHAR)), 1642 "expected %s, got %s\n", xmltestbodyA, wine_dbgstr_w(bstrResponse)); 1643 SysFreeString(bstrResponse); 1644 1645 hr = IXMLHttpRequest_get_responseBody(xhr, NULL); 1646 EXPECT_HR(hr, E_INVALIDARG); 1647 1648 V_VT(&varbody) = VT_EMPTY; 1649 hr = IXMLHttpRequest_get_responseBody(xhr, &varbody); 1650 EXPECT_HR(hr, S_OK); 1651 ok(V_VT(&varbody) == (VT_ARRAY|VT_UI1), "got type %d, expected %d\n", V_VT(&varbody), VT_ARRAY|VT_UI1); 1652 ok(SafeArrayGetDim(V_ARRAY(&varbody)) == 1, "got %d, expected one dimension\n", SafeArrayGetDim(V_ARRAY(&varbody))); 1653 1654 bound = -1; 1655 hr = SafeArrayGetLBound(V_ARRAY(&varbody), 1, &bound); 1656 EXPECT_HR(hr, S_OK); 1657 ok(bound == 0, "got %d, expected zero bound\n", bound); 1658 1659 hr = SafeArrayAccessData(V_ARRAY(&varbody), &ptr); 1660 EXPECT_HR(hr, S_OK); 1661 ok(memcmp(ptr, xmltestbodyA, sizeof(xmltestbodyA)-1) == 0, "got wrong body data\n"); 1662 SafeArrayUnaccessData(V_ARRAY(&varbody)); 1663 1664 VariantClear(&varbody); 1665 1666 /* get_responseStream */ 1667 hr = IXMLHttpRequest_get_responseStream(xhr, NULL); 1668 EXPECT_HR(hr, E_INVALIDARG); 1669 1670 V_VT(&varbody) = VT_EMPTY; 1671 hr = IXMLHttpRequest_get_responseStream(xhr, &varbody); 1672 ok(V_VT(&varbody) == VT_UNKNOWN, "got type %d\n", V_VT(&varbody)); 1673 EXPECT_HR(hr, S_OK); 1674 EXPECT_REF(V_UNKNOWN(&varbody), 1); 1675 1676 g = NULL; 1677 hr = GetHGlobalFromStream((IStream*)V_UNKNOWN(&varbody), &g); 1678 EXPECT_HR(hr, S_OK); 1679 ok(g != NULL, "got %p\n", g); 1680 VariantClear(&varbody); 1681 1682 IDispatch_Release(event); 1683 1684 /* test if referrer header is sent */ 1685 test_open(xhr, "GET", referertesturl, S_OK); 1686 1687 V_VT(&varbody) = VT_EMPTY; 1688 hr = IXMLHttpRequest_send(xhr, varbody); 1689 ok(hr == S_OK, "got 0x%08x\n", hr); 1690 hr = IXMLHttpRequest_get_responseText(xhr, &str); 1691 ok(hr == S_OK, "got 0x%08x\n", hr); 1692 ok(!lstrcmpW(str, norefererW), "got response text %s\n", wine_dbgstr_w(str)); 1693 SysFreeString(str); 1694 1695 /* interaction with object site */ 1696 hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site); 1697 EXPECT_HR(hr, S_OK); 1698 1699 hr = IObjectWithSite_SetSite(obj_site, NULL); 1700 ok(hr == S_OK, "got 0x%08x\n", hr); 1701 1702 hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site2); 1703 EXPECT_HR(hr, S_OK); 1704 ok(obj_site == obj_site2 || broken(obj_site != obj_site2), "got new instance\n"); 1705 IObjectWithSite_Release(obj_site2); 1706 1707 set_xhr_site(xhr); 1708 1709 test_open(xhr, "GET", "tests/referer.php", S_OK); 1710 str1 = a2bstr("http://test.winehq.org/"); 1711 1712 V_VT(&varbody) = VT_EMPTY; 1713 hr = IXMLHttpRequest_send(xhr, varbody); 1714 ok(hr == S_OK, "got 0x%08x\n", hr); 1715 1716 hr = IXMLHttpRequest_get_responseText(xhr, &str); 1717 ok(hr == S_OK, "got 0x%08x\n", hr); 1718 ok(!lstrcmpW(str, str1), "got response text %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str1)); 1719 SysFreeString(str); 1720 SysFreeString(str1); 1721 1722 /* try to set site another time */ 1723 hr = IObjectWithSite_SetSite(obj_site, &testsite); 1724 EXPECT_HR(hr, S_OK); 1725 1726 IObjectWithSite_Release(obj_site); 1727 1728 /* HEAD request */ 1729 hr = IXMLHttpRequest_put_onreadystatechange(xhr, NULL); 1730 ok(hr == S_OK, "Failed to reset state change handler, hr %#x.\n", hr); 1731 1732 test_open(xhr, "HEAD", xmltestA, S_OK); 1733 1734 V_VT(&varbody) = VT_EMPTY; 1735 hr = IXMLHttpRequest_send(xhr, varbody); 1736 ok(hr == S_OK, "Failed to send HEAD request, hr %#x.\n", hr); 1737 1738 str = NULL; 1739 hr = IXMLHttpRequest_get_responseText(xhr, &str); 1740 ok(hr == S_OK, "Failed to get response text, hr %#x.\n", hr); 1741 ok(!*str, "Unexpected text %s.\n", wine_dbgstr_w(str)); 1742 SysFreeString(str); 1743 1744 hr = IXMLHttpRequest_getAllResponseHeaders(xhr, &str); 1745 ok(hr == S_OK, "Failed to get response headers, hr %#x.\n", hr); 1746 ok(str && *str, "Expected response headers.\n"); 1747 SysFreeString(str); 1748 1749 IXMLHttpRequest_Release(xhr); 1750 free_bstrs(); 1751 } 1752 1753 static void test_safe_httpreq(void) 1754 { 1755 IXMLHttpRequest *xhr; 1756 1757 xhr = create_xhr(); 1758 1759 set_safety_opt((IUnknown*)xhr, INTERFACESAFE_FOR_UNTRUSTED_DATA, -1); 1760 set_xhr_site(xhr); 1761 1762 /* different scheme */ 1763 test_open(xhr, "GET", "https://test.winehq.org/tests/hello.html", E_ACCESSDENIED); 1764 1765 /* different host */ 1766 test_open(xhr, "GET", "http://tests.winehq.org/tests/hello.html", E_ACCESSDENIED); 1767 test_open(xhr, "GET", "http://www.test.winehq.org/tests/hello.html", E_ACCESSDENIED); 1768 1769 IXMLHttpRequest_Release(xhr); 1770 free_bstrs(); 1771 } 1772 1773 static void test_supporterrorinfo(void) 1774 { 1775 HRESULT hr; 1776 IXMLHttpRequest *xhr; 1777 IServerXMLHTTPRequest *server_xhr; 1778 ISupportErrorInfo *errorinfo, *errorinfo2; 1779 1780 xhr = create_xhr(); 1781 1782 EXPECT_REF(xhr, 1); 1783 hr = IXMLHttpRequest_QueryInterface(xhr, &IID_ISupportErrorInfo, (void **)&errorinfo); 1784 ok(hr == S_OK, "Failed to get ISupportErrorInfo, hr %#x.\n", hr); 1785 EXPECT_REF(xhr, 2); 1786 1787 hr = IXMLHttpRequest_QueryInterface(xhr, &IID_ISupportErrorInfo, (void **)&errorinfo2); 1788 ok(hr == S_OK, "Failed to get ISupportErrorInfo, hr %#x.\n", hr); 1789 ok(errorinfo == errorinfo2, "Unexpected error info instance.\n"); 1790 EXPECT_REF(xhr, 3); 1791 1792 ISupportErrorInfo_Release(errorinfo2); 1793 ISupportErrorInfo_Release(errorinfo); 1794 1795 IXMLHttpRequest_Release(xhr); 1796 1797 /* ServerXMLHTTP */ 1798 server_xhr = create_server_xhr(); 1799 1800 EXPECT_REF(server_xhr, 1); 1801 hr = IServerXMLHTTPRequest_QueryInterface(server_xhr, &IID_ISupportErrorInfo, (void **)&errorinfo); 1802 ok(hr == S_OK, "Failed to get ISupportErrorInfo, hr %#x.\n", hr); 1803 EXPECT_REF(server_xhr, 2); 1804 1805 hr = IServerXMLHTTPRequest_QueryInterface(server_xhr, &IID_ISupportErrorInfo, (void **)&errorinfo2); 1806 ok(hr == S_OK, "Failed to get ISupportErrorInfo, hr %#x.\n", hr); 1807 ok(errorinfo == errorinfo2, "Unexpected error info instance.\n"); 1808 EXPECT_REF(server_xhr, 3); 1809 1810 ISupportErrorInfo_Release(errorinfo2); 1811 ISupportErrorInfo_Release(errorinfo); 1812 1813 IServerXMLHTTPRequest_Release(server_xhr); 1814 } 1815 1816 START_TEST(httpreq) 1817 { 1818 IXMLHttpRequest *xhr; 1819 1820 CoInitialize(NULL); 1821 1822 if (!(xhr = create_xhr())) 1823 { 1824 win_skip("IXMLHTTPRequest is not available\n"); 1825 CoUninitialize(); 1826 return; 1827 } 1828 1829 IXMLHttpRequest_Release(xhr); 1830 1831 test_XMLHTTP(); 1832 test_safe_httpreq(); 1833 test_supporterrorinfo(); 1834 1835 CoUninitialize(); 1836 } 1837