40#define DEFINE_EXPECT(func) \
41 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
43#define SET_EXPECT(func) \
44 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
46#define CHECK_EXPECT2(func) \
49 ok(expect_ ##func, "unexpected call " #func "\n"); \
50 called_ ## func = TRUE; \
53#define CHECK_EXPECT(func) \
55 CHECK_EXPECT2(func); \
56 expect_ ## func = FALSE; \
59#define CHECK_CALLED(func) \
61 ok(called_ ## func, "expected " #func "\n"); \
62 expect_ ## func = called_ ## func = FALSE; \
75#define test_disp(u,id) _test_disp(__LINE__,u,id)
83 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (
void**)&dispex);
89 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
91 ok_(__FILE__,
line) (ticnt == 1,
"ticnt=%u\n", ticnt);
104 ITypeInfo_ReleaseTypeAttr(
typeinfo, type_attr);
108 IDispatchEx_Release(dispex);
111#define test_event_args(a,b,c,d,e,f,g) _test_event_args(__LINE__,a,b,c,d,e,f,g)
115 ok_(__FILE__,
line) (
id == DISPID_VALUE,
"id = %d\n",
id);
118 ok_(__FILE__,
line) (pdp->cArgs == 1,
"pdp->cArgs = %d\n", pdp->cArgs);
119 ok_(__FILE__,
line) (pdp->cNamedArgs == 1,
"pdp->cNamedArgs = %d\n", pdp->cNamedArgs);
120 ok_(__FILE__,
line) (pdp->rgdispidNamedArgs[0] ==
DISPID_THIS,
"pdp->rgdispidNamedArgs[0] = %d\n",
121 pdp->rgdispidNamedArgs[0]);
123 ok_(__FILE__,
line) (pvarRes !=
NULL,
"pvarRes == NULL\n");
125 ok_(__FILE__,
line) (!pspCaller,
"pspCaller != NULL\n");
159 ok(0,
"unexpected call\n");
166 ok(0,
"unexpected call\n");
174 ok(0,
"unexpected call\n");
180 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
UINT *puArgErr)
182 ok(0,
"unexpected call\n");
188 ok(0,
"unexpected call\n");
200 ok(0,
"unexpected call\n");
206 ok(0,
"unexpected call\n");
212 ok(0,
"unexpected call\n");
218 ok(0,
"unexpected call\n");
224 ok(0,
"unexpected call\n");
234 if (!expect_xmlhttprequest_onreadystatechange_loading)
237 hres = IHTMLXMLHttpRequest_get_readyState(
xhr, &
val);
247 CHECK_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
258 ok(0,
"unexpected readyState: %d\n",
val);
293 ok(0,
"unexpected call\n");
327 ok(0,
"unexpected call\n");
349 ok(
hres ==
S_OK,
"QueryInterface(IID_IConnectionPointContainer) failed: %08x\n",
hres);
352 IConnectionPointContainer_Release(
container);
355 hres = IConnectionPoint_Advise(
cp, unk_advise, &
cookie);
356 IConnectionPoint_Release(
cp);
386 IHTMLWindow5 *window5;
388 IHTMLXMLHttpRequestFactory *
factory;
391 hres = IHTMLDocument2_get_parentWindow(doc, &
window);
395 hres = IHTMLWindow2_QueryInterface(
window, &IID_IHTMLWindow5, (
void**)&window5);
396 IHTMLWindow2_Release(
window);
398 win_skip(
"IHTMLWindow5 not supported\n");
403 hres = IHTMLWindow5_get_XMLHttpRequest(window5, &
var);
404 IHTMLWindow5_Release(window5);
410 ok(
hres ==
S_OK,
"QueryInterface(IID_IHTMLXMLHttpRequestFactory) failed: %08x\n",
hres);
414 IHTMLXMLHttpRequestFactory_Release(
factory);
424 char all[4096],
buf[512];
427 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(
xhr, &all_header);
429 ok(all_header !=
NULL,
"all_header == NULL\n");
434 for(
i = 0;
i <
num; ++
i) {
448 ok(
strstr(all,
buf) !=
NULL,
"AllResponseHeaders(%s) don't have expected substr(%s)\n", all,
buf);
452static void test_sync_xhr(IHTMLDocument2 *doc,
const char *xml_url,
const char *expect_text)
459 static const struct HEADER_TYPE expect_headers[] = {
460 {
"Server",
"Apache"},
461 {
"Accept-Ranges",
"bytes"},
462 {
"Content-Length",
"51"},
463 {
"Content-Type",
"application/xml"}
471 hres = IHTMLXMLHttpRequest_get_onreadystatechange(
xhr, &
var);
477 hres = IHTMLXMLHttpRequest_put_onreadystatechange(
xhr,
var);
481 hres = IHTMLXMLHttpRequest_get_onreadystatechange(
xhr, &
var);
486 hres = IHTMLXMLHttpRequest_get_readyState(
xhr,
NULL);
490 hres = IHTMLXMLHttpRequest_get_readyState(
xhr, &
val);
492 ok(
val == 0,
"Expect UNSENT, got %d\n",
val);
498 hres = IHTMLXMLHttpRequest_get_status(
xhr, &
val);
500 ok(
val == 0,
"Expect 0, got %d\n",
val);
502 hres = IHTMLXMLHttpRequest_get_statusText(
xhr,
NULL);
505 hres = IHTMLXMLHttpRequest_get_statusText(
xhr, &
text);
510 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(
xhr, &
text);
522 V_BOOL(&vbool) = VARIANT_FALSE;
525 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
534 IHTMLXMLHttpRequest_Release(
xhr);
540 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(
xhr, &
text);
550 hres = IHTMLXMLHttpRequest_get_status(
xhr, &
val);
552 ok(
val == 0,
"Expect 0, got %d\n",
val);
554 hres = IHTMLXMLHttpRequest_get_statusText(
xhr, &
text);
559 hres = IHTMLXMLHttpRequest_get_readyState(
xhr, &
val);
561 ok(
val == 1,
"Expect OPENED, got %d\n",
val);
563 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
564 SET_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
565 SET_EXPECT(xmlhttprequest_onreadystatechange_loading);
566 SET_EXPECT(xmlhttprequest_onreadystatechange_done);
568 hres = IHTMLXMLHttpRequest_send(
xhr, vempty);
571 CHECK_CALLED(xmlhttprequest_onreadystatechange_headers_received);
572 CHECK_CALLED(xmlhttprequest_onreadystatechange_loading);
583 test_header(expect_headers,
sizeof(expect_headers)/
sizeof(expect_headers[0]));
586 hres = IHTMLXMLHttpRequest_get_status(
xhr, &
val);
588 ok(
val == 200,
"Expect 200, got %d\n",
val);
590 hres = IHTMLXMLHttpRequest_get_statusText(
xhr, &
text);
598 hres = IHTMLXMLHttpRequest_get_readyState(
xhr, &
val);
600 ok(
val == 4,
"Expect DONE, got %d\n",
val);
602 hres = IHTMLXMLHttpRequest_get_responseText(
xhr, &
text);
610 IHTMLXMLHttpRequest_Release(
xhr);
614static void test_async_xhr(IHTMLDocument2 *doc,
const char *xml_url,
const char *expect_text)
621 static const struct HEADER_TYPE expect_headers[] = {
622 {
"Content-Length",
"51"},
623 {
"Content-Type",
"application/xml"}
632 hres = IHTMLXMLHttpRequest_put_onreadystatechange(
xhr,
var);
636 hres = IHTMLXMLHttpRequest_get_onreadystatechange(
xhr, &
var);
649 "Expect E_POINTER, got %08x\n",
hres);
656 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(
xhr,
NULL);
660 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(
xhr, &
text);
665 hres = IHTMLXMLHttpRequest_get_status(
xhr, &
val);
667 ok(
val == 0,
"Expect 0, got %d\n",
val);
670 hres = IHTMLXMLHttpRequest_get_statusText(
xhr, &
text);
675 hres = IHTMLXMLHttpRequest_get_readyState(
xhr, &
val);
677 ok(
val == 0,
"Expect UNSENT, got %d\n",
val);
682 V_BOOL(&vbool) = VARIANT_TRUE;
685 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
694 IHTMLXMLHttpRequest_Release(
xhr);
700 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(
xhr, &
text);
710 hres = IHTMLXMLHttpRequest_get_status(
xhr, &
val);
712 ok(
val == 0,
"Expect 0, got %d\n",
val);
714 hres = IHTMLXMLHttpRequest_get_statusText(
xhr, &
text);
719 hres = IHTMLXMLHttpRequest_get_readyState(
xhr, &
val);
721 ok(
val == 1,
"Expect OPENED, got %d\n",
val);
723 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
724 SET_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
725 SET_EXPECT(xmlhttprequest_onreadystatechange_loading);
726 SET_EXPECT(xmlhttprequest_onreadystatechange_done);
728 hres = IHTMLXMLHttpRequest_send(
xhr, vempty);
732 pump_msgs(&called_xmlhttprequest_onreadystatechange_done);
734 CHECK_CALLED(xmlhttprequest_onreadystatechange_headers_received);
735 CHECK_CALLED(xmlhttprequest_onreadystatechange_loading);
744 IHTMLXMLHttpRequest_Release(
xhr);
750 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(
xhr, &
text);
751 ok(
hres ==
S_OK,
"getAllResponseHeader failed, got %08x\n",
hres);
756 test_header(expect_headers,
sizeof(expect_headers)/
sizeof(expect_headers[0]));
759 hres = IHTMLXMLHttpRequest_get_status(
xhr, &
val);
761 ok(
val == 200,
"Expect 200, got %d\n",
val);
764 hres = IHTMLXMLHttpRequest_get_statusText(
xhr, &
text);
771 hres = IHTMLXMLHttpRequest_get_readyState(
xhr, &
val);
773 ok(
val == 4,
"Expect DONE, got %d\n",
val);
776 hres = IHTMLXMLHttpRequest_get_responseText(
xhr, &
text);
784 IHTMLXMLHttpRequest_Release(
xhr);
798 V_BOOL(&vbool) = VARIANT_TRUE;
801 trace(
"abort before send() is fired\n");
808 hres = IHTMLXMLHttpRequest_put_onreadystatechange(
xhr,
var);
810 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
815 hres = IHTMLXMLHttpRequest_abort(
xhr);
818 hres = IHTMLXMLHttpRequest_get_status(
xhr, &
val);
820 ok(
val == 0,
"Expect 0, got %d\n",
val);
822 hres = IHTMLXMLHttpRequest_get_readyState(
xhr, &
val);
824 ok(
val == 0,
"Expect UNSENT, got %d\n",
val);
826 IHTMLXMLHttpRequest_Release(
xhr);
829 trace(
"abort after send() is fired\n");
833 hres = IHTMLXMLHttpRequest_put_onreadystatechange(
xhr,
var);
835 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
842 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
843 SET_EXPECT(xmlhttprequest_onreadystatechange_done);
844 hres = IHTMLXMLHttpRequest_send(
xhr, vempty);
848 hres = IHTMLXMLHttpRequest_abort(
xhr);
852 hres = IHTMLXMLHttpRequest_get_readyState(
xhr, &
val);
854 ok(
val == 0,
"Expect UNSENT, got %d\n",
val);
856 hres = IHTMLXMLHttpRequest_get_status(
xhr, &
val);
858 ok(
val == 0,
"Expect 0, got %d\n",
val);
863 IHTMLXMLHttpRequest_Release(
xhr);
887 CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, &IID_IHTMLDocument2,
891 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistMoniker,
892 (
void**)&persist_mon);
893 ok(
hres ==
S_OK,
"IHTMLDocument2_QueryInterface failed: 0x%08x\n",
hres);
895 hres = IPersistMoniker_Load(persist_mon,
FALSE, url_mon,
bc,
899 IPersistMoniker_Release(persist_mon);
900 IMoniker_Release(url_mon);
901 IBindCtx_Release(
bc);
915 static const char start_url[] =
"http://test.winehq.org/tests/hello.html";
916 static const char xml_url[] =
"http://test.winehq.org/tests/xmltest.xml";
917 static const char large_page_url[] =
"http://test.winehq.org/tests/data.php";
918 static const char expect_response_text[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
930 IHTMLDocument2_Release(doc);
char * strcat(char *DstString, const char *SrcString)
char * strstr(char *String1, char *String2)
char * strcpy(char *DstString, const char *SrcString)
#define WideCharToMultiByte
#define MultiByteToWideChar
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define DISPID_READYSTATE
static const char * strw(LPCWSTR x)
static IHTMLWindow2 * window
static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
static void test_header(const struct HEADER_TYPE expect[], int num)
#define test_event_args(a, b, c, d, e, f, g)
static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
static void test_async_xhr_abort(IHTMLDocument2 *doc, const char *xml_url)
static void _test_event_args(unsigned line, const IID *dispiid, DISPID id, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
#define CHECK_EXPECT(func)
static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
#define DEFINE_EXPECT(func)
static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
static int readystatechange_cnt
static void pump_msgs(BOOL *b)
static BSTR a2bstr(const char *str)
static IHTMLXMLHttpRequest * xhr
static int strcmp_wa(LPCWSTR strw, const char *stra)
static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
static void test_async_xhr(IHTMLDocument2 *doc, const char *xml_url, const char *expect_text)
static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
#define CHECK_EXPECT2(func)
static void test_sync_xhr(IHTMLDocument2 *doc, const char *xml_url, const char *expect_text)
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
static IDispatchEx xmlhttprequest_onreadystatechange_obj
static void create_xmlhttprequest(IHTMLDocument2 *doc)
static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
#define CHECK_CALLED(func)
static IHTMLDocument2 * create_doc_from_url(const char *start_url)
static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface, REFIID riid, void **ppv)
static IHTMLDocument2 * notif_doc
static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
static IDispatchExVtbl xmlhttprequest_onreadystatechangeFuncVtbl
static HRESULT WINAPI xmlhttprequest_onreadystatechange(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
static IPropertyNotifySink PropertyNotifySink
static void _test_disp(unsigned line, IUnknown *unk, const IID *diid)
static VARIANTARG static DISPID
interface IHTMLWindow2 IHTMLWindow2
#define STGM_SHARE_EXCLUSIVE
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
const GUID IID_IConnectionPointContainer
const GUID IID_IPropertyNotifySink
#define IsEqualGUID(rguid1, rguid2)
static __inline const char * wine_dbgstr_guid(const GUID *id)
#define disable_success_count
TW_UINT32 TW_UINT16 TW_UINT16 MSG
HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk)
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
void WINAPI VariantInit(VARIANTARG *pVarg)
_In_ DWORD _Out_ _In_ WORD wFlags
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)