ReactOS 0.4.15-dev-7928-g68a8619
xmlhttprequest.c File Reference
#include "precomp.h"
Include dependency graph for xmlhttprequest.c:

Go to the source code of this file.

Classes

struct  HEADER_TYPE
 

Macros

#define DEFINE_EXPECT(func)    static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
 
#define SET_EXPECT(func)    do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
 
#define CHECK_EXPECT2(func)
 
#define CHECK_EXPECT(func)
 
#define CHECK_CALLED(func)
 
#define test_disp(u, id)   _test_disp(__LINE__,u,id)
 
#define test_event_args(a, b, c, d, e, f, g)   _test_event_args(__LINE__,a,b,c,d,e,f,g)
 

Functions

static BSTR a2bstr (const char *str)
 
static int strcmp_wa (LPCWSTR strw, const char *stra)
 
 DEFINE_EXPECT (xmlhttprequest_onreadystatechange_opened)
 
 DEFINE_EXPECT (xmlhttprequest_onreadystatechange_headers_received)
 
 DEFINE_EXPECT (xmlhttprequest_onreadystatechange_loading)
 
 DEFINE_EXPECT (xmlhttprequest_onreadystatechange_done)
 
static void _test_disp (unsigned line, IUnknown *unk, const IID *diid)
 
static void _test_event_args (unsigned line, const IID *dispiid, DISPID id, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
 
static HRESULT WINAPI DispatchEx_QueryInterface (IDispatchEx *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI DispatchEx_AddRef (IDispatchEx *iface)
 
static ULONG WINAPI DispatchEx_Release (IDispatchEx *iface)
 
static HRESULT WINAPI DispatchEx_GetTypeInfoCount (IDispatchEx *iface, UINT *pctinfo)
 
static HRESULT WINAPI DispatchEx_GetTypeInfo (IDispatchEx *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI DispatchEx_GetIDsOfNames (IDispatchEx *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI DispatchEx_Invoke (IDispatchEx *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
static HRESULT WINAPI DispatchEx_GetDispID (IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
 
static HRESULT WINAPI DispatchEx_DeleteMemberByName (IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
 
static HRESULT WINAPI DispatchEx_DeleteMemberByDispID (IDispatchEx *iface, DISPID id)
 
static HRESULT WINAPI DispatchEx_GetMemberProperties (IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
 
static HRESULT WINAPI DispatchEx_GetMemberName (IDispatchEx *iface, DISPID id, BSTR *pbstrName)
 
static HRESULT WINAPI DispatchEx_GetNextDispID (IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
 
static HRESULT WINAPI DispatchEx_GetNameSpaceParent (IDispatchEx *iface, IUnknown **ppunk)
 
static HRESULT WINAPI xmlhttprequest_onreadystatechange (IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
 
static HRESULT WINAPI PropertyNotifySink_QueryInterface (IPropertyNotifySink *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI PropertyNotifySink_AddRef (IPropertyNotifySink *iface)
 
static ULONG WINAPI PropertyNotifySink_Release (IPropertyNotifySink *iface)
 
static HRESULT WINAPI PropertyNotifySink_OnChanged (IPropertyNotifySink *iface, DISPID dispID)
 
static HRESULT WINAPI PropertyNotifySink_OnRequestEdit (IPropertyNotifySink *iface, DISPID dispID)
 
static void do_advise (IUnknown *unk, REFIID riid, IUnknown *unk_advise)
 
static void pump_msgs (BOOL *b)
 
static void create_xmlhttprequest (IHTMLDocument2 *doc)
 
static void test_header (const struct HEADER_TYPE expect[], int num)
 
static void test_sync_xhr (IHTMLDocument2 *doc, const char *xml_url, const char *expect_text)
 
static void test_async_xhr (IHTMLDocument2 *doc, const char *xml_url, const char *expect_text)
 
static void test_async_xhr_abort (IHTMLDocument2 *doc, const char *xml_url)
 
static IHTMLDocument2 * create_doc_from_url (const char *start_url)
 
 START_TEST (xmlhttprequest)
 

Variables

static IHTMLXMLHttpRequest * xhr = NULL
 
static BSTR content_type = NULL
 
static int loading_cnt = 0
 
static int readystatechange_cnt = 0
 
static IDispatchExVtbl xmlhttprequest_onreadystatechangeFuncVtbl
 
static IDispatchEx xmlhttprequest_onreadystatechange_obj = { &xmlhttprequest_onreadystatechangeFuncVtbl }
 
static BOOL doc_complete
 
static IHTMLDocument2 * notif_doc
 
static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
 
static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl }
 

Macro Definition Documentation

◆ CHECK_CALLED

#define CHECK_CALLED (   func)
Value:
do { \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define FALSE
Definition: types.h:117
GLenum func
Definition: glext.h:6028
#define expect_(expected, got, precision)
Definition: font.c:29

Definition at line 59 of file xmlhttprequest.c.

◆ CHECK_EXPECT

#define CHECK_EXPECT (   func)
Value:
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)

Definition at line 53 of file xmlhttprequest.c.

◆ CHECK_EXPECT2

#define CHECK_EXPECT2 (   func)
Value:
do { \
trace(#func "\n"); \
ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \
}while(0)
#define TRUE
Definition: types.h:120

Definition at line 46 of file xmlhttprequest.c.

◆ DEFINE_EXPECT

#define DEFINE_EXPECT (   func)     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE

Definition at line 40 of file xmlhttprequest.c.

◆ SET_EXPECT

#define SET_EXPECT (   func)     do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)

Definition at line 43 of file xmlhttprequest.c.

◆ test_disp

#define test_disp (   u,
  id 
)    _test_disp(__LINE__,u,id)

Definition at line 75 of file xmlhttprequest.c.

◆ test_event_args

#define test_event_args (   a,
  b,
  c,
  d,
  e,
  f,
  g 
)    _test_event_args(__LINE__,a,b,c,d,e,f,g)

Definition at line 111 of file xmlhttprequest.c.

Function Documentation

◆ _test_disp()

static void _test_disp ( unsigned  line,
IUnknown unk,
const IID diid 
)
static

Definition at line 76 of file xmlhttprequest.c.

77{
78 IDispatchEx *dispex;
80 UINT ticnt;
82
83 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
84 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
85 if(FAILED(hres))
86 return;
87
88 ticnt = 0xdeadbeef;
89 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
90 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
91 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
92
93 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
94 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
95
96 if(SUCCEEDED(hres)) {
97 TYPEATTR *type_attr;
98
99 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
100 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
101 ok_(__FILE__,line) (IsEqualGUID(&type_attr->guid, diid), "unexpected guid %s\n",
102 wine_dbgstr_guid(&type_attr->guid));
103
104 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
105 ITypeInfo_Release(typeinfo);
106 }
107
108 IDispatchEx_Release(dispex);
109}
#define ok_(x1, x2)
Definition: atltest.h:61
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hres
Definition: protocol.c:465
unsigned int UINT
Definition: ndis.h:50
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
Definition: parser.c:49

Referenced by _test_event_args().

◆ _test_event_args()

static void _test_event_args ( unsigned  line,
const IID dispiid,
DISPID  id,
WORD  wFlags,
DISPPARAMS *  pdp,
VARIANT pvarRes,
EXCEPINFO *  pei,
IServiceProvider pspCaller 
)
static

Definition at line 112 of file xmlhttprequest.c.

114{
115 ok_(__FILE__,line) (id == DISPID_VALUE, "id = %d\n", id);
116 ok_(__FILE__,line) (wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
117 ok_(__FILE__,line) (pdp != NULL, "pdp == NULL\n");
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]);
122 ok_(__FILE__,line) (V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(rgvarg) = %d\n", V_VT(pdp->rgvarg));
123 ok_(__FILE__,line) (pvarRes != NULL, "pvarRes == NULL\n");
124 ok_(__FILE__,line) (pei != NULL, "pei == NULL");
125 ok_(__FILE__,line) (!pspCaller, "pspCaller != NULL\n");
126
127 if(dispiid)
128 _test_disp(line, (IUnknown*)V_DISPATCH(pdp->rgvarg), dispiid);
129}
#define NULL
Definition: types.h:112
@ VT_DISPATCH
Definition: compat.h:2304
GLuint id
Definition: glext.h:5910
static void _test_disp(unsigned line, IUnknown *unk, const IID *diid)
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define V_VT(A)
Definition: oleauto.h:211
#define V_DISPATCH(A)
Definition: oleauto.h:239
#define DISPID_THIS
Definition: olectl.h:395
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531

◆ a2bstr()

static BSTR a2bstr ( const char str)
static

Definition at line 21 of file xmlhttprequest.c.

22{
23 BSTR ret;
24 int len;
25
26 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
29
30 return ret;
31}
#define CP_ACP
Definition: compat.h:109
OLECHAR * BSTR
Definition: compat.h:2293
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
const WCHAR * str
int ret

Referenced by create_doc_from_url(), START_TEST(), test_async_xhr(), test_async_xhr_abort(), test_header(), and test_sync_xhr().

◆ create_doc_from_url()

static IHTMLDocument2 * create_doc_from_url ( const char start_url)
static

Definition at line 870 of file xmlhttprequest.c.

871{
872 BSTR url;
873 IBindCtx *bc;
874 IMoniker *url_mon;
875 IPersistMoniker *persist_mon;
876 IHTMLDocument2 *doc;
878
879 hres = CreateBindCtx(0, &bc);
880 ok(hres == S_OK, "CreateBindCtx failed: 0x%08x\n", hres);
881
882 url = a2bstr(start_url);
883 hres = CreateURLMoniker(NULL, url, &url_mon);
884 ok(hres == S_OK, "CreateURLMoniker failed: 0x%08x\n", hres);
885
886 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL,
887 CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, &IID_IHTMLDocument2,
888 (void**)&doc);
889 ok(hres == S_OK, "CoCreateInstance failed: 0x%08x\n", hres);
890
891 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistMoniker,
892 (void**)&persist_mon);
893 ok(hres == S_OK, "IHTMLDocument2_QueryInterface failed: 0x%08x\n", hres);
894
895 hres = IPersistMoniker_Load(persist_mon, FALSE, url_mon, bc,
897 ok(hres == S_OK, "IPersistMoniker_Load failed: 0x%08x\n", hres);
898
899 IPersistMoniker_Release(persist_mon);
900 IMoniker_Release(url_mon);
901 IBindCtx_Release(bc);
903
905 notif_doc = doc;
908
909 return doc;
910}
#define ok(value,...)
Definition: atltest.h:57
PBATCH_CONTEXT bc
Definition: batch.c:67
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
static const WCHAR url[]
Definition: encode.c:1432
static void pump_msgs(BOOL *b)
static BSTR a2bstr(const char *str)
static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
static BOOL doc_complete
static IHTMLDocument2 * notif_doc
static IPropertyNotifySink PropertyNotifySink
#define STGM_READWRITE
Definition: objbase.h:919
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:923
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
const GUID IID_IPropertyNotifySink
HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk)
Definition: umon.c:732

Referenced by START_TEST().

◆ create_xmlhttprequest()

static void create_xmlhttprequest ( IHTMLDocument2 *  doc)
static

Definition at line 383 of file xmlhttprequest.c.

384{
386 IHTMLWindow5 *window5;
387 VARIANT var;
388 IHTMLXMLHttpRequestFactory *factory;
390
391 hres = IHTMLDocument2_get_parentWindow(doc, &window);
392 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
393 ok(window != NULL, "window == NULL\n");
394
395 hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow5, (void**)&window5);
396 IHTMLWindow2_Release(window);
397 if(FAILED(hres)) {
398 win_skip("IHTMLWindow5 not supported\n");
399 return;
400 }
401
403 hres = IHTMLWindow5_get_XMLHttpRequest(window5, &var);
404 IHTMLWindow5_Release(window5);
405 ok(hres == S_OK, "get_XMLHttpRequest failed: %08x\n", hres);
406 ok(V_VT(&var) == VT_DISPATCH, "V_VT(&var) is %08x, expected VT_DISPATCH\n", V_VT(&var));
407
408 hres = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IHTMLXMLHttpRequestFactory, (void**)&factory);
410 ok(hres == S_OK, "QueryInterface(IID_IHTMLXMLHttpRequestFactory) failed: %08x\n", hres);
411 ok(factory != NULL, "factory == NULL\n");
412
413 hres = IHTMLXMLHttpRequestFactory_create(factory, &xhr);
414 IHTMLXMLHttpRequestFactory_Release(factory);
415 ok(hres == S_OK, "create failed: %08x\n", hres);
416 ok(xhr != NULL, "xhr == NULL\n");
417}
const char * var
Definition: shader.c:5666
static IHTMLWindow2 * window
Definition: events.c:77
static IHTMLXMLHttpRequest * xhr
interface IHTMLWindow2 IHTMLWindow2
Definition: mshtmhst.idl:64
#define win_skip
Definition: test.h:160
Definition: main.c:439
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568

Referenced by test_async_xhr(), test_async_xhr_abort(), and test_sync_xhr().

◆ DEFINE_EXPECT() [1/4]

DEFINE_EXPECT ( xmlhttprequest_onreadystatechange_done  )

◆ DEFINE_EXPECT() [2/4]

DEFINE_EXPECT ( xmlhttprequest_onreadystatechange_headers_received  )

◆ DEFINE_EXPECT() [3/4]

DEFINE_EXPECT ( xmlhttprequest_onreadystatechange_loading  )

◆ DEFINE_EXPECT() [4/4]

DEFINE_EXPECT ( xmlhttprequest_onreadystatechange_opened  )

◆ DispatchEx_AddRef()

static ULONG WINAPI DispatchEx_AddRef ( IDispatchEx iface)
static

Definition at line 147 of file xmlhttprequest.c.

148{
149 return 2;
150}

◆ DispatchEx_DeleteMemberByDispID()

static HRESULT WINAPI DispatchEx_DeleteMemberByDispID ( IDispatchEx iface,
DISPID  id 
)
static

Definition at line 198 of file xmlhttprequest.c.

199{
200 ok(0, "unexpected call\n");
201 return E_NOTIMPL;
202}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DispatchEx_DeleteMemberByName()

static HRESULT WINAPI DispatchEx_DeleteMemberByName ( IDispatchEx iface,
BSTR  bstrName,
DWORD  grfdex 
)
static

Definition at line 192 of file xmlhttprequest.c.

193{
194 ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
195 return E_NOTIMPL;
196}
#define wine_dbgstr_w
Definition: kernel32.h:34

◆ DispatchEx_GetDispID()

static HRESULT WINAPI DispatchEx_GetDispID ( IDispatchEx iface,
BSTR  bstrName,
DWORD  grfdex,
DISPID pid 
)
static

Definition at line 186 of file xmlhttprequest.c.

187{
188 ok(0, "unexpected call\n");
189 return E_NOTIMPL;
190}

◆ DispatchEx_GetIDsOfNames()

static HRESULT WINAPI DispatchEx_GetIDsOfNames ( IDispatchEx iface,
REFIID  riid,
LPOLESTR rgszNames,
UINT  cNames,
LCID  lcid,
DISPID rgDispId 
)
static

Definition at line 170 of file xmlhttprequest.c.

173{
174 ok(0, "unexpected call\n");
175 return E_NOTIMPL;
176}

◆ DispatchEx_GetMemberName()

static HRESULT WINAPI DispatchEx_GetMemberName ( IDispatchEx iface,
DISPID  id,
BSTR pbstrName 
)
static

Definition at line 210 of file xmlhttprequest.c.

211{
212 ok(0, "unexpected call\n");
213 return E_NOTIMPL;
214}

◆ DispatchEx_GetMemberProperties()

static HRESULT WINAPI DispatchEx_GetMemberProperties ( IDispatchEx iface,
DISPID  id,
DWORD  grfdexFetch,
DWORD pgrfdex 
)
static

Definition at line 204 of file xmlhttprequest.c.

205{
206 ok(0, "unexpected call\n");
207 return E_NOTIMPL;
208}

◆ DispatchEx_GetNameSpaceParent()

static HRESULT WINAPI DispatchEx_GetNameSpaceParent ( IDispatchEx iface,
IUnknown **  ppunk 
)
static

Definition at line 222 of file xmlhttprequest.c.

223{
224 ok(0, "unexpected call\n");
225 return E_NOTIMPL;
226}

◆ DispatchEx_GetNextDispID()

static HRESULT WINAPI DispatchEx_GetNextDispID ( IDispatchEx iface,
DWORD  grfdex,
DISPID  id,
DISPID pid 
)
static

Definition at line 216 of file xmlhttprequest.c.

217{
218 ok(0, "unexpected call\n");
219 return E_NOTIMPL;
220}

◆ DispatchEx_GetTypeInfo()

static HRESULT WINAPI DispatchEx_GetTypeInfo ( IDispatchEx iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 163 of file xmlhttprequest.c.

165{
166 ok(0, "unexpected call\n");
167 return E_NOTIMPL;
168}

◆ DispatchEx_GetTypeInfoCount()

static HRESULT WINAPI DispatchEx_GetTypeInfoCount ( IDispatchEx iface,
UINT pctinfo 
)
static

Definition at line 157 of file xmlhttprequest.c.

158{
159 ok(0, "unexpected call\n");
160 return E_NOTIMPL;
161}

◆ DispatchEx_Invoke()

static HRESULT WINAPI DispatchEx_Invoke ( IDispatchEx iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT pVarResult,
EXCEPINFO *  pExcepInfo,
UINT puArgErr 
)
static

Definition at line 178 of file xmlhttprequest.c.

181{
182 ok(0, "unexpected call\n");
183 return E_NOTIMPL;
184}

◆ DispatchEx_QueryInterface()

static HRESULT WINAPI DispatchEx_QueryInterface ( IDispatchEx iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 131 of file xmlhttprequest.c.

132{
133 *ppv = NULL;
134
137 || IsEqualGUID(riid, &IID_IDispatchEx))
138 *ppv = iface;
139 else {
140 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
141 return E_NOINTERFACE;
142 }
143
144 return S_OK;
145}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
const GUID IID_IDispatch
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ DispatchEx_Release()

static ULONG WINAPI DispatchEx_Release ( IDispatchEx iface)
static

Definition at line 152 of file xmlhttprequest.c.

153{
154 return 1;
155}

◆ do_advise()

static void do_advise ( IUnknown unk,
REFIID  riid,
IUnknown unk_advise 
)
static

Definition at line 341 of file xmlhttprequest.c.

342{
347
348 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
349 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
350
351 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
352 IConnectionPointContainer_Release(container);
353 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
354
355 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
356 IConnectionPoint_Release(cp);
357 ok(hres == S_OK, "Advise failed: %08x\n", hres);
358}
unsigned long DWORD
Definition: ntddk_ex.h:95
POINT cp
Definition: magnifier.c:59
const GUID IID_IConnectionPointContainer
Definition: cookie.c:34

Referenced by create_doc_from_url().

◆ PropertyNotifySink_AddRef()

static ULONG WINAPI PropertyNotifySink_AddRef ( IPropertyNotifySink iface)
static

Definition at line 297 of file xmlhttprequest.c.

298{
299 return 2;
300}

◆ PropertyNotifySink_OnChanged()

static HRESULT WINAPI PropertyNotifySink_OnChanged ( IPropertyNotifySink iface,
DISPID  dispID 
)
static

Definition at line 307 of file xmlhttprequest.c.

308{
309 if(dispID == DISPID_READYSTATE){
310 BSTR state;
312
313 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
314 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
315
316 if(!strcmp_wa(state, "complete"))
318
320 }
321
322 return S_OK;
323}
static int state
Definition: maze.c:121
#define DISPID_READYSTATE
Definition: idispids.h:22
static int strcmp_wa(LPCWSTR strw, const char *stra)

◆ PropertyNotifySink_OnRequestEdit()

static HRESULT WINAPI PropertyNotifySink_OnRequestEdit ( IPropertyNotifySink iface,
DISPID  dispID 
)
static

Definition at line 325 of file xmlhttprequest.c.

326{
327 ok(0, "unexpected call\n");
328 return E_NOTIMPL;
329}

◆ PropertyNotifySink_QueryInterface()

static HRESULT WINAPI PropertyNotifySink_QueryInterface ( IPropertyNotifySink iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 285 of file xmlhttprequest.c.

287{
289 *ppv = iface;
290 return S_OK;
291 }
292
293 ok(0, "unexpected call\n");
294 return E_NOINTERFACE;
295}

◆ PropertyNotifySink_Release()

static ULONG WINAPI PropertyNotifySink_Release ( IPropertyNotifySink iface)
static

Definition at line 302 of file xmlhttprequest.c.

303{
304 return 1;
305}

◆ pump_msgs()

static void pump_msgs ( BOOL b)
static

Definition at line 360 of file xmlhttprequest.c.

361{
362 MSG msg;
363
364 if(b) {
365 while(!*b && GetMessageW(&msg, NULL, 0, 0)) {
368 }
369 }else {
370 while(PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
373 }
374 }
375}
#define msg(x)
Definition: auth_time.c:54
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
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)
#define PM_REMOVE
Definition: winuser.h:1196
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)

Referenced by create_doc_from_url(), and test_async_xhr().

◆ START_TEST()

START_TEST ( xmlhttprequest  )

Definition at line 912 of file xmlhttprequest.c.

913{
914 IHTMLDocument2 *doc;
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";
919
921
922 content_type = a2bstr("Content-Type");
923 doc = create_doc_from_url(start_url);
924 if(doc) {
925 test_sync_xhr(doc, xml_url, expect_response_text);
926 test_sync_xhr(doc, large_page_url, NULL);
927 test_async_xhr(doc, xml_url, expect_response_text);
928 test_async_xhr(doc, large_page_url, NULL);
929 test_async_xhr_abort(doc, large_page_url);
930 IHTMLDocument2_Release(doc);
931 }
933
935}
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static BSTR content_type
static void test_async_xhr_abort(IHTMLDocument2 *doc, const char *xml_url)
static void test_async_xhr(IHTMLDocument2 *doc, const char *xml_url, const char *expect_text)
static void test_sync_xhr(IHTMLDocument2 *doc, const char *xml_url, const char *expect_text)
static IHTMLDocument2 * create_doc_from_url(const char *start_url)

◆ strcmp_wa()

static int strcmp_wa ( LPCWSTR  strw,
const char stra 
)
static

Definition at line 33 of file xmlhttprequest.c.

34{
35 CHAR buf[512];
36 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
37 return lstrcmpA(stra, buf);
38}
#define WideCharToMultiByte
Definition: compat.h:111
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
static const char * strw(LPCWSTR x)
Definition: actctx.c:49
char CHAR
Definition: xmlstorage.h:175

Referenced by PropertyNotifySink_OnChanged(), test_async_xhr(), test_header(), and test_sync_xhr().

◆ test_async_xhr()

static void test_async_xhr ( IHTMLDocument2 *  doc,
const char xml_url,
const char expect_text 
)
static

Definition at line 614 of file xmlhttprequest.c.

615{
616 VARIANT vbool, vempty, var;
617 BSTR method, url;
618 BSTR text;
619 LONG val;
621 static const struct HEADER_TYPE expect_headers[] = {
622 {"Content-Length", "51"},
623 {"Content-Type", "application/xml"}
624 };
625
627 if(!xhr)
628 return;
629
630 V_VT(&var) = VT_DISPATCH;
632 hres = IHTMLXMLHttpRequest_put_onreadystatechange(xhr, var);
633 ok(hres == S_OK, "put_onreadystatechange failed: %08x\n", hres);
634
635 V_VT(&var) = VT_EMPTY;
636 hres = IHTMLXMLHttpRequest_get_onreadystatechange(xhr, &var);
637 ok(hres == S_OK, "get_onreadystatechange failed: %08x\n", hres);
638 ok(V_VT(&var) == VT_DISPATCH, "V_VT(onreadystatechange) = %d\n", V_VT(&var));
639 ok(V_DISPATCH(&var) == (IDispatch*)&xmlhttprequest_onreadystatechange_obj, "unexpected onreadystatechange value\n");
640
641 hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, NULL, &text);
642 ok(hres == E_INVALIDARG, "Expect E_INVALIDARG, got %08x\n", hres);
643
644 hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, NULL);
645 ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
646
647 hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, NULL, NULL);
648 ok(hres == E_POINTER || broken(hres == E_INVALIDARG), /* Vista and before */
649 "Expect E_POINTER, got %08x\n", hres);
650
651 text = (BSTR)0xdeadbeef;
652 hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text);
653 ok(hres == E_FAIL, "got %08x\n", hres);
654 ok(text == NULL, "text = %p\n", text);
655
656 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, NULL);
657 ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
658
659 text = (BSTR)0xdeadbeef;
660 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text);
661 ok(hres == E_FAIL, "got %08x\n", hres);
662 ok(text == NULL, "text = %p\n", text);
663
664 val = 0xdeadbeef;
665 hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
666 ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
667 ok(val == 0, "Expect 0, got %d\n", val);
668
669 text = (BSTR)0xdeadbeef;
670 hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
671 ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
672 ok(text == NULL, "Expect NULL, got %p\n", text);
673
674 val = 0xdeadbeef;
675 hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
676 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
677 ok(val == 0, "Expect UNSENT, got %d\n", val);
678
679 method = a2bstr("GET");
680 url = a2bstr(xml_url);
681 V_VT(&vbool) = VT_BOOL;
682 V_BOOL(&vbool) = VARIANT_TRUE;
683 V_VT(&vempty) = VT_EMPTY;
684
685 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
686 hres = IHTMLXMLHttpRequest_open(xhr, method, url, vbool, vempty, vempty);
687 ok(hres == S_OK, "open failed: %08x\n", hres);
688 CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
689
692
693 if(FAILED(hres)) {
694 IHTMLXMLHttpRequest_Release(xhr);
695 xhr = NULL;
696 return;
697 }
698
699 text = (BSTR)0xdeadbeef;
700 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text);
701 ok(hres == E_FAIL, "got %08x\n", hres);
702 ok(text == NULL, "text = %p\n", text);
703
704 text = (BSTR)0xdeadbeef;
705 hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text);
706 ok(hres == E_FAIL, "got %08x\n", hres);
707 ok(text == NULL, "text = %p\n", text);
708
709 val = 0xdeadbeef;
710 hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
711 ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
712 ok(val == 0, "Expect 0, got %d\n", val);
713
714 hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
715 ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
716 ok(text == NULL, "Expect NULL, got %p\n", text);
717
718 val = 0xdeadbeef;
719 hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
720 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
721 ok(val == 1, "Expect OPENED, got %d\n", val);
722
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);
727 loading_cnt = 0;
728 hres = IHTMLXMLHttpRequest_send(xhr, vempty);
729
730 ok(hres == S_OK, "send failed: %08x\n", hres);
731 if(SUCCEEDED(hres))
732 pump_msgs(&called_xmlhttprequest_onreadystatechange_done);
733 todo_wine CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
734 CHECK_CALLED(xmlhttprequest_onreadystatechange_headers_received);
735 CHECK_CALLED(xmlhttprequest_onreadystatechange_loading);
736 CHECK_CALLED(xmlhttprequest_onreadystatechange_done);
737 /* Workaround for loading large files */
738 if(expect_text)
739 ok(loading_cnt == 1, "loading_cnt = %d\n", loading_cnt);
740 else
741 todo_wine ok(loading_cnt == 1, "loading_cnt = %d\n", loading_cnt);
742
743 if(FAILED(hres)) {
744 IHTMLXMLHttpRequest_Release(xhr);
745 xhr = NULL;
746 return;
747 }
748
749 text = NULL;
750 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text);
751 ok(hres == S_OK, "getAllResponseHeader failed, got %08x\n", hres);
752 ok(text != NULL, "text == NULL\n");
754
755 if(expect_text)
756 test_header(expect_headers, sizeof(expect_headers)/sizeof(expect_headers[0]));
757
758 val = 0xdeadbeef;
759 hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
760 ok(hres == S_OK, "get_status failed: %08x\n", hres);
761 ok(val == 200, "Expect 200, got %d\n", val);
762
763 text = NULL;
764 hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
765 ok(hres == S_OK, "get_statusText failed: %08x\n", hres);
766 ok(text != NULL, "text == NULL\n");
767 ok(!strcmp_wa(text, "OK"), "Expected \"OK\", got %s\n", wine_dbgstr_w(text));
769
770 val = 0xdeadbeef;
771 hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
772 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
773 ok(val == 4, "Expect DONE, got %d\n", val);
774
775 text = NULL;
776 hres = IHTMLXMLHttpRequest_get_responseText(xhr, &text);
777 ok(hres == S_OK, "get_responseText failed: %08x\n", hres);
778 ok(text != NULL, "test == NULL\n");
779 if(expect_text)
780 ok(!strcmp_wa(text, expect_text), "expect %s, got %s\n",
781 expect_text, wine_dbgstr_w(text));
783
784 IHTMLXMLHttpRequest_Release(xhr);
785 xhr = NULL;
786}
#define broken(x)
Definition: _sntprintf.h:21
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
@ VT_BOOL
Definition: compat.h:2306
@ VT_EMPTY
Definition: compat.h:2295
const WCHAR * text
Definition: package.c:1799
method
Definition: dragdrop.c:54
GLuint GLfloat * val
Definition: glext.h:7180
#define SET_EXPECT(func)
static void test_header(const struct HEADER_TYPE expect[], int num)
static int loading_cnt
static IDispatchEx xmlhttprequest_onreadystatechange_obj
static void create_xmlhttprequest(IHTMLDocument2 *doc)
#define CHECK_CALLED(func)
#define todo_wine
Definition: custom.c:79
#define V_BOOL(A)
Definition: oleauto.h:224
long LONG
Definition: pedump.c:60
#define E_POINTER
Definition: winerror.h:2365

Referenced by START_TEST().

◆ test_async_xhr_abort()

static void test_async_xhr_abort ( IHTMLDocument2 *  doc,
const char xml_url 
)
static

Definition at line 788 of file xmlhttprequest.c.

789{
790 VARIANT vbool, vempty, var;
791 BSTR method, url;
792 LONG val;
794
795 method = a2bstr("GET");
796 url = a2bstr(xml_url);
797 V_VT(&vbool) = VT_BOOL;
798 V_BOOL(&vbool) = VARIANT_TRUE;
799 V_VT(&vempty) = VT_EMPTY;
800
801 trace("abort before send() is fired\n");
803 if(!xhr)
804 return;
805
806 V_VT(&var) = VT_DISPATCH;
808 hres = IHTMLXMLHttpRequest_put_onreadystatechange(xhr, var);
809
810 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
811 hres = IHTMLXMLHttpRequest_open(xhr, method, url, vbool, vempty, vempty);
812 ok(hres == S_OK, "open failed: %08x\n", hres);
813 CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
814
815 hres = IHTMLXMLHttpRequest_abort(xhr);
816 ok(hres == S_OK, "abort failed: %08x\n", hres);
817
818 hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
819 ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
820 ok(val == 0, "Expect 0, got %d\n", val);
821
822 hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
823 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
824 ok(val == 0, "Expect UNSENT, got %d\n", val);
825
826 IHTMLXMLHttpRequest_Release(xhr);
827 xhr = NULL;
828
829 trace("abort after send() is fired\n");
831 V_VT(&var) = VT_DISPATCH;
833 hres = IHTMLXMLHttpRequest_put_onreadystatechange(xhr, var);
834
835 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
836 hres = IHTMLXMLHttpRequest_open(xhr, method, url, vbool, vempty, vempty);
837 ok(hres == S_OK, "open failed: %08x\n", hres);
838 CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
839
840 loading_cnt = 0;
842 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
843 SET_EXPECT(xmlhttprequest_onreadystatechange_done);
844 hres = IHTMLXMLHttpRequest_send(xhr, vempty);
845 ok(hres == S_OK, "send failed: %08x\n", hres);
846 todo_wine CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
847
848 hres = IHTMLXMLHttpRequest_abort(xhr);
849 ok(hres == S_OK, "abort failed: %08x\n", hres);
850 CHECK_CALLED(xmlhttprequest_onreadystatechange_done);
851
852 hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
853 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
854 ok(val == 0, "Expect UNSENT, got %d\n", val);
855
856 hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
857 ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
858 ok(val == 0, "Expect 0, got %d\n", val);
859
860 ok(loading_cnt == 0, "loading_cnt = %d, expect 0, loading_cnt\n", loading_cnt);
861 todo_wine ok(readystatechange_cnt == 2, "readystatechange_cnt = %d, expect 2\n", readystatechange_cnt);
862
863 IHTMLXMLHttpRequest_Release(xhr);
864 xhr = NULL;
865
868}
#define trace
Definition: atltest.h:70
static int readystatechange_cnt

Referenced by START_TEST().

◆ test_header()

static void test_header ( const struct HEADER_TYPE  expect[],
int  num 
)
static

Definition at line 419 of file xmlhttprequest.c.

420{
421 int i;
422 BSTR key, text, all_header;
424 char all[4096], buf[512];
425
426 all_header = NULL;
427 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &all_header);
428 ok(hres == S_OK, "getAllResponseHeader failed: %08x\n", hres);
429 ok(all_header != NULL, "all_header == NULL\n");
430
431 WideCharToMultiByte(CP_UTF8, 0, all_header, -1, all, sizeof(all), NULL, NULL);
432 SysFreeString(all_header);
433
434 for(i = 0; i < num; ++i) {
435 text = NULL;
436 key = a2bstr(expect[i].key);
437 hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, key, &text);
438 ok(hres == S_OK, "getResponseHeader failed, got %08x\n", hres);
439 ok(text != NULL, "text == NULL\n");
441 "Expect %s: %s, got %s\n", expect[i].key, expect[i].value, wine_dbgstr_w(text));
444
445 strcpy(buf, expect[i].key);
446 strcat(buf, ": ");
448 ok(strstr(all, buf) != NULL, "AllResponseHeaders(%s) don't have expected substr(%s)\n", all, buf);
449 }
450}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLuint GLuint num
Definition: glext.h:9618
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
Definition: glfuncs.h:248
#define CP_UTF8
Definition: nls.h:20
Definition: copy.c:22
Definition: pdh_main.c:94

Referenced by test_async_xhr(), and test_sync_xhr().

◆ test_sync_xhr()

static void test_sync_xhr ( IHTMLDocument2 *  doc,
const char xml_url,
const char expect_text 
)
static

Definition at line 452 of file xmlhttprequest.c.

453{
454 VARIANT vbool, vempty, var;
455 BSTR method, url;
456 BSTR text;
457 LONG val;
459 static const struct HEADER_TYPE expect_headers[] = {
460 {"Server", "Apache"},
461 {"Accept-Ranges", "bytes"},
462 {"Content-Length", "51"},
463 {"Content-Type", "application/xml"}
464 };
465
467 if(!xhr)
468 return;
469
470 V_VT(&var) = VT_EMPTY;
471 hres = IHTMLXMLHttpRequest_get_onreadystatechange(xhr, &var);
472 ok(hres == S_OK, "get_onreadystatechange failed: %08x\n", hres);
473 ok(V_VT(&var) == VT_NULL, "V_VT(onreadystatechange) = %d\n", V_VT(&var));
474
475 V_VT(&var) = VT_DISPATCH;
477 hres = IHTMLXMLHttpRequest_put_onreadystatechange(xhr, var);
478 ok(hres == S_OK, "put_onreadystatechange failed: %08x\n", hres);
479
480 V_VT(&var) = VT_EMPTY;
481 hres = IHTMLXMLHttpRequest_get_onreadystatechange(xhr, &var);
482 ok(hres == S_OK, "get_onreadystatechange failed: %08x\n", hres);
483 ok(V_VT(&var) == VT_DISPATCH, "V_VT(onreadystatechange) = %d\n", V_VT(&var));
484 ok(V_DISPATCH(&var) == (IDispatch*)&xmlhttprequest_onreadystatechange_obj, "unexpected onreadystatechange value\n");
485
486 hres = IHTMLXMLHttpRequest_get_readyState(xhr, NULL);
487 ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
488
489 val = 0xdeadbeef;
490 hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
491 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
492 ok(val == 0, "Expect UNSENT, got %d\n", val);
493
494 hres = IHTMLXMLHttpRequest_get_status(xhr, NULL);
495 ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
496
497 val = 0xdeadbeef;
498 hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
499 ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
500 ok(val == 0, "Expect 0, got %d\n", val);
501
502 hres = IHTMLXMLHttpRequest_get_statusText(xhr, NULL);
503 ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
504
505 hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
506 ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
507 ok(text == NULL, "Expect NULL, got %p\n", text);
508
509 text = (BSTR)0xdeadbeef;
510 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text);
511 ok(hres == E_FAIL, "got %08x\n", hres);
512 ok(text == NULL, "text = %p\n", text);
513
514 text = (BSTR)0xdeadbeef;
515 hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text);
516 ok(hres == E_FAIL, "got %08x\n", hres);
517 ok(text == NULL, "text = %p\n", text);
518
519 method = a2bstr("GET");
520 url = a2bstr(xml_url);
521 V_VT(&vbool) = VT_BOOL;
522 V_BOOL(&vbool) = VARIANT_FALSE;
523 V_VT(&vempty) = VT_EMPTY;
524
525 SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
526 hres = IHTMLXMLHttpRequest_open(xhr, method, url, vbool, vempty, vempty);
527 todo_wine ok(hres == S_OK, "open failed: %08x\n", hres); /* Gecko 30+ only supports async */
528 todo_wine CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
529
532
533 if(FAILED(hres)) {
534 IHTMLXMLHttpRequest_Release(xhr);
535 xhr = NULL;
536 return;
537 }
538
539 text = (BSTR)0xdeadbeef;
540 hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text);
541 ok(hres == E_FAIL, "got %08x\n", hres);
542 ok(text == NULL, "text = %p\n", text);
543
544 text = (BSTR)0xdeadbeef;
545 hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text);
546 ok(hres == E_FAIL, "got %08x\n", hres);
547 ok(text == NULL, "text = %p\n", text);
548
549 val = 0xdeadbeef;
550 hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
551 ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
552 ok(val == 0, "Expect 0, got %d\n", val);
553
554 hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
555 ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
556 ok(text == NULL, "Expect NULL, got %p\n", text);
557
558 val = 0xdeadbeef;
559 hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
560 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
561 ok(val == 1, "Expect OPENED, got %d\n", val);
562
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);
567 loading_cnt = 0;
568 hres = IHTMLXMLHttpRequest_send(xhr, vempty);
569 ok(hres == S_OK, "send failed: %08x\n", hres);
570 CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
571 CHECK_CALLED(xmlhttprequest_onreadystatechange_headers_received);
572 CHECK_CALLED(xmlhttprequest_onreadystatechange_loading);
573 CHECK_CALLED(xmlhttprequest_onreadystatechange_done);
574 ok(loading_cnt == 1, "loading_cnt = %d\n", loading_cnt);
575
576 text = NULL;
577 hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text);
578 ok(hres == S_OK, "getResponseHeader failed, got %08x\n", hres);
579 ok(text != NULL, "text == NULL\n");
581
582 if(expect_text)
583 test_header(expect_headers, sizeof(expect_headers)/sizeof(expect_headers[0]));
584
585 val = 0xdeadbeef;
586 hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
587 ok(hres == S_OK, "get_status failed: %08x\n", hres);
588 ok(val == 200, "Expect 200, got %d\n", val);
589
590 hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
591 ok(hres == S_OK, "get_statusText failed: %08x\n", hres);
592 ok(text != NULL, "text == NULL\n");
593 ok(!strcmp_wa(text, "OK"),
594 "Expected \"OK\", got %s\n", wine_dbgstr_w(text));
596
597 val = 0xdeadbeef;
598 hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
599 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
600 ok(val == 4, "Expect DONE, got %d\n", val);
601
602 hres = IHTMLXMLHttpRequest_get_responseText(xhr, &text);
603 ok(hres == S_OK, "get_responseText failed: %08x\n", hres);
604 ok(text != NULL, "test == NULL\n");
605 if(expect_text)
606 ok(!strcmp_wa(text, expect_text), "expect %s, got %s\n",
607 expect_text, wine_dbgstr_w(text));
609
610 IHTMLXMLHttpRequest_Release(xhr);
611 xhr = NULL;
612}
@ VT_NULL
Definition: compat.h:2296

Referenced by START_TEST().

◆ xmlhttprequest_onreadystatechange()

static HRESULT WINAPI xmlhttprequest_onreadystatechange ( IDispatchEx iface,
DISPID  id,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pdp,
VARIANT pvarRes,
EXCEPINFO *  pei,
IServiceProvider pspCaller 
)
static

Definition at line 228 of file xmlhttprequest.c.

230{
231 LONG val;
233
234 if (!expect_xmlhttprequest_onreadystatechange_loading)
235 test_event_args(&DIID_DispHTMLXMLHttpRequest, id, wFlags, pdp, pvarRes, pei, pspCaller);
236
237 hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
239 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
241
242 switch(val) {
243 case 1:
244 CHECK_EXPECT(xmlhttprequest_onreadystatechange_opened);
245 break;
246 case 2:
247 CHECK_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
248 break;
249 case 3:
250 loading_cnt++;
252 CHECK_EXPECT2(xmlhttprequest_onreadystatechange_loading);
253 break;
254 case 4:
255 CHECK_EXPECT(xmlhttprequest_onreadystatechange_done);
256 break;
257 default:
258 ok(0, "unexpected readyState: %d\n", val);
259 }
260 return S_OK;
261}
#define test_event_args(a, b, c, d, e, f, g)
#define CHECK_EXPECT(func)
#define CHECK_EXPECT2(func)
#define disable_success_count
Definition: test.h:181

Variable Documentation

◆ content_type

◆ doc_complete

BOOL doc_complete
static

Definition at line 282 of file xmlhttprequest.c.

Referenced by create_doc_from_url(), and PropertyNotifySink_OnChanged().

◆ loading_cnt

int loading_cnt = 0
static

◆ notif_doc

IHTMLDocument2* notif_doc
static

Definition at line 283 of file xmlhttprequest.c.

Referenced by create_doc_from_url(), and PropertyNotifySink_OnChanged().

◆ PropertyNotifySink

IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl }
static

Definition at line 339 of file xmlhttprequest.c.

Referenced by create_doc_from_url().

◆ PropertyNotifySinkVtbl

IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
static
Initial value:
= {
}
static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface, REFIID riid, void **ppv)

Definition at line 331 of file xmlhttprequest.c.

◆ readystatechange_cnt

int readystatechange_cnt = 0
static

Definition at line 68 of file xmlhttprequest.c.

Referenced by test_async_xhr_abort(), and xmlhttprequest_onreadystatechange().

◆ xhr

◆ xmlhttprequest_onreadystatechange_obj

IDispatchEx xmlhttprequest_onreadystatechange_obj = { &xmlhttprequest_onreadystatechangeFuncVtbl }
static

Definition at line 280 of file xmlhttprequest.c.

Referenced by test_async_xhr(), test_async_xhr_abort(), and test_sync_xhr().

◆ xmlhttprequest_onreadystatechangeFuncVtbl

IDispatchExVtbl xmlhttprequest_onreadystatechangeFuncVtbl
static
Initial value:
= {
}
static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
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)
static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
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)

Definition at line 263 of file xmlhttprequest.c.