2015-06-25 14:16:53 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Zhenbo Li
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2015-12-25 08:30:06 +01:00
|
|
|
#include <stdio.h>
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "mshtml.h"
|
2015-12-25 08:30:06 +01:00
|
|
|
#include "objsafe.h"
|
2019-12-17 15:54:38 +01:00
|
|
|
#include "wine/test.h"
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
#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) \
|
|
|
|
do { \
|
|
|
|
trace(#func "\n"); \
|
|
|
|
ok(expect_ ##func, "unexpected call " #func "\n"); \
|
|
|
|
called_ ## func = TRUE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_EXPECT(func) \
|
|
|
|
do { \
|
|
|
|
CHECK_EXPECT2(func); \
|
|
|
|
expect_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_CALLED(func) \
|
|
|
|
do { \
|
|
|
|
ok(called_ ## func, "expected " #func "\n"); \
|
|
|
|
expect_ ## func = called_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
static IHTMLXMLHttpRequest *xhr = NULL;
|
2015-08-05 03:23:32 +02:00
|
|
|
static BSTR content_type = NULL;
|
2015-08-19 03:33:41 +02:00
|
|
|
static int loading_cnt = 0;
|
|
|
|
static int readystatechange_cnt = 0;
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
DEFINE_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
DEFINE_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
|
|
|
|
DEFINE_EXPECT(xmlhttprequest_onreadystatechange_loading);
|
|
|
|
DEFINE_EXPECT(xmlhttprequest_onreadystatechange_done);
|
|
|
|
|
|
|
|
#define test_disp(u,id) _test_disp(__LINE__,u,id)
|
2016-02-08 18:12:54 +01:00
|
|
|
static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const IID *broken_diid)
|
2015-06-25 14:16:53 +02:00
|
|
|
{
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
UINT ticnt;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
|
|
|
|
ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ticnt = 0xdeadbeef;
|
|
|
|
hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
|
|
|
|
ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
|
|
|
|
ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
|
|
|
|
|
|
|
|
hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
|
|
|
|
ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
TYPEATTR *type_attr;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
|
|
|
|
ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
|
2016-02-08 18:12:54 +01:00
|
|
|
ok_(__FILE__,line) (IsEqualGUID(&type_attr->guid, diid)
|
|
|
|
|| broken(broken_diid && IsEqualGUID(&type_attr->guid, broken_diid)),
|
|
|
|
"unexpected guid %s\n", wine_dbgstr_guid(&type_attr->guid));
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
}
|
|
|
|
|
2016-02-08 18:12:54 +01:00
|
|
|
#define test_event_args(a,b,c,d,e,f,g,h) _test_event_args(__LINE__,a,b,c,d,e,f,g,h)
|
|
|
|
static void _test_event_args(unsigned line, const IID *dispiid, const IID *broken_dispiid, DISPID id, WORD wFlags,
|
|
|
|
DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
|
2015-06-25 14:16:53 +02:00
|
|
|
{
|
|
|
|
ok_(__FILE__,line) (id == DISPID_VALUE, "id = %d\n", id);
|
|
|
|
ok_(__FILE__,line) (wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
|
|
|
|
ok_(__FILE__,line) (pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok_(__FILE__,line) (pdp->cArgs == 1, "pdp->cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok_(__FILE__,line) (pdp->cNamedArgs == 1, "pdp->cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok_(__FILE__,line) (pdp->rgdispidNamedArgs[0] == DISPID_THIS, "pdp->rgdispidNamedArgs[0] = %d\n",
|
|
|
|
pdp->rgdispidNamedArgs[0]);
|
|
|
|
ok_(__FILE__,line) (V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(rgvarg) = %d\n", V_VT(pdp->rgvarg));
|
|
|
|
ok_(__FILE__,line) (pvarRes != NULL, "pvarRes == NULL\n");
|
2018-01-05 06:02:30 +01:00
|
|
|
ok_(__FILE__,line) (pei != NULL, "pei == NULL\n");
|
2015-06-25 14:16:53 +02:00
|
|
|
ok_(__FILE__,line) (!pspCaller, "pspCaller != NULL\n");
|
|
|
|
|
|
|
|
if(dispiid)
|
2016-02-08 18:12:54 +01:00
|
|
|
_test_disp(line, (IUnknown*)V_DISPATCH(pdp->rgvarg), dispiid, broken_dispiid);
|
2015-06-25 14:16:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2019-08-12 14:16:59 +02:00
|
|
|
if(!IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
&& !IsEqualGUID(riid, &IID_IDispatch)
|
|
|
|
&& !IsEqualGUID(riid, &IID_IDispatchEx)) {
|
|
|
|
*ppv = NULL;
|
2015-06-25 14:16:53 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-08-12 14:16:59 +02:00
|
|
|
*ppv = iface;
|
2015-06-25 14:16:53 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlhttprequest_onreadystatechange(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
|
|
|
|
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
|
|
|
|
{
|
|
|
|
LONG val;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2016-02-08 18:12:54 +01:00
|
|
|
test_event_args(&DIID_DispHTMLXMLHttpRequest, &IID_IHTMLXMLHttpRequest, id, wFlags, pdp, pvarRes, pei, pspCaller);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
|
|
|
|
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
|
2015-08-19 03:33:41 +02:00
|
|
|
readystatechange_cnt++;
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
switch(val) {
|
|
|
|
case 1:
|
|
|
|
CHECK_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
CHECK_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
|
|
|
|
break;
|
|
|
|
case 3:
|
2015-08-19 03:33:41 +02:00
|
|
|
loading_cnt++;
|
|
|
|
CHECK_EXPECT2(xmlhttprequest_onreadystatechange_loading);
|
2015-06-25 14:16:53 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
CHECK_EXPECT(xmlhttprequest_onreadystatechange_done);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ok(0, "unexpected readyState: %d\n", val);
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDispatchExVtbl xmlhttprequest_onreadystatechangeFuncVtbl = {
|
|
|
|
DispatchEx_QueryInterface,
|
|
|
|
DispatchEx_AddRef,
|
|
|
|
DispatchEx_Release,
|
|
|
|
DispatchEx_GetTypeInfoCount,
|
|
|
|
DispatchEx_GetTypeInfo,
|
|
|
|
DispatchEx_GetIDsOfNames,
|
|
|
|
DispatchEx_Invoke,
|
|
|
|
DispatchEx_GetDispID,
|
|
|
|
xmlhttprequest_onreadystatechange,
|
|
|
|
DispatchEx_DeleteMemberByName,
|
|
|
|
DispatchEx_DeleteMemberByDispID,
|
|
|
|
DispatchEx_GetMemberProperties,
|
|
|
|
DispatchEx_GetMemberName,
|
|
|
|
DispatchEx_GetNextDispID,
|
|
|
|
DispatchEx_GetNameSpaceParent
|
|
|
|
};
|
|
|
|
static IDispatchEx xmlhttprequest_onreadystatechange_obj = { &xmlhttprequest_onreadystatechangeFuncVtbl };
|
|
|
|
|
2015-07-07 16:49:42 +02:00
|
|
|
static BOOL doc_complete;
|
|
|
|
static IHTMLDocument2 *notif_doc;
|
|
|
|
|
|
|
|
static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
|
|
|
|
REFIID riid, void**ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
|
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
|
|
|
|
{
|
|
|
|
if(dispID == DISPID_READYSTATE){
|
|
|
|
BSTR state;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IHTMLDocument2_get_readyState(notif_doc, &state);
|
|
|
|
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
|
|
|
|
|
2020-02-12 00:32:48 +01:00
|
|
|
if(!lstrcmpW(state, L"complete"))
|
2015-07-07 16:49:42 +02:00
|
|
|
doc_complete = TRUE;
|
|
|
|
|
|
|
|
SysFreeString(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
|
|
|
|
PropertyNotifySink_QueryInterface,
|
|
|
|
PropertyNotifySink_AddRef,
|
|
|
|
PropertyNotifySink_Release,
|
|
|
|
PropertyNotifySink_OnChanged,
|
|
|
|
PropertyNotifySink_OnRequestEdit
|
|
|
|
};
|
|
|
|
|
|
|
|
static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
|
|
|
|
|
|
|
|
static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
|
|
|
|
{
|
|
|
|
IConnectionPointContainer *container;
|
|
|
|
IConnectionPoint *cp;
|
|
|
|
DWORD cookie;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
|
|
|
|
ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
|
|
|
|
IConnectionPointContainer_Release(container);
|
|
|
|
ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
|
|
|
|
IConnectionPoint_Release(cp);
|
|
|
|
ok(hres == S_OK, "Advise failed: %08x\n", hres);
|
|
|
|
}
|
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
static void pump_msgs(BOOL *b)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
if(b) {
|
|
|
|
while(!*b && GetMessageW(&msg, NULL, 0, 0)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
while(PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-05 03:23:32 +02:00
|
|
|
struct HEADER_TYPE {
|
2020-02-12 00:32:49 +01:00
|
|
|
const WCHAR *key;
|
2020-02-12 00:32:48 +01:00
|
|
|
const WCHAR *value;
|
2015-08-05 03:23:32 +02:00
|
|
|
};
|
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
static void create_xmlhttprequest(IHTMLDocument2 *doc)
|
|
|
|
{
|
|
|
|
IHTMLWindow2 *window;
|
|
|
|
IHTMLWindow5 *window5;
|
|
|
|
VARIANT var;
|
|
|
|
IHTMLXMLHttpRequestFactory *factory;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IHTMLDocument2_get_parentWindow(doc, &window);
|
|
|
|
ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
|
|
|
|
ok(window != NULL, "window == NULL\n");
|
|
|
|
|
|
|
|
hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow5, (void**)&window5);
|
|
|
|
IHTMLWindow2_Release(window);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
win_skip("IHTMLWindow5 not supported\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-17 11:32:15 +02:00
|
|
|
VariantInit(&var);
|
2015-06-25 14:16:53 +02:00
|
|
|
hres = IHTMLWindow5_get_XMLHttpRequest(window5, &var);
|
|
|
|
IHTMLWindow5_Release(window5);
|
|
|
|
ok(hres == S_OK, "get_XMLHttpRequest failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH, "V_VT(&var) is %08x, expected VT_DISPATCH\n", V_VT(&var));
|
|
|
|
|
|
|
|
hres = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IHTMLXMLHttpRequestFactory, (void**)&factory);
|
|
|
|
VariantClear(&var);
|
|
|
|
ok(hres == S_OK, "QueryInterface(IID_IHTMLXMLHttpRequestFactory) failed: %08x\n", hres);
|
|
|
|
ok(factory != NULL, "factory == NULL\n");
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequestFactory_create(factory, &xhr);
|
|
|
|
IHTMLXMLHttpRequestFactory_Release(factory);
|
|
|
|
ok(hres == S_OK, "create failed: %08x\n", hres);
|
|
|
|
ok(xhr != NULL, "xhr == NULL\n");
|
|
|
|
}
|
|
|
|
|
2015-08-05 03:23:32 +02:00
|
|
|
static void test_header(const struct HEADER_TYPE expect[], int num)
|
|
|
|
{
|
|
|
|
int i;
|
2020-02-12 00:32:48 +01:00
|
|
|
BSTR key, text, all;
|
2015-08-05 03:23:32 +02:00
|
|
|
HRESULT hres;
|
2020-02-12 00:32:48 +01:00
|
|
|
WCHAR buf[512];
|
2015-08-05 03:23:43 +02:00
|
|
|
|
2020-02-12 00:32:48 +01:00
|
|
|
all = NULL;
|
|
|
|
hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &all);
|
2015-08-05 03:23:43 +02:00
|
|
|
ok(hres == S_OK, "getAllResponseHeader failed: %08x\n", hres);
|
2020-02-12 00:32:48 +01:00
|
|
|
ok(all != NULL, "all == NULL\n");
|
2015-08-05 03:23:32 +02:00
|
|
|
|
|
|
|
for(i = 0; i < num; ++i) {
|
|
|
|
text = NULL;
|
2020-02-12 00:32:49 +01:00
|
|
|
key = SysAllocString(expect[i].key);
|
2015-08-05 03:23:32 +02:00
|
|
|
hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, key, &text);
|
|
|
|
ok(hres == S_OK, "getResponseHeader failed, got %08x\n", hres);
|
|
|
|
ok(text != NULL, "text == NULL\n");
|
2020-02-12 00:32:48 +01:00
|
|
|
ok(!lstrcmpW(text, expect[i].value),
|
2020-02-12 00:32:49 +01:00
|
|
|
"Expect %s: %s, got %s\n", wine_dbgstr_w(expect[i].key), wine_dbgstr_w(expect[i].value),
|
|
|
|
wine_dbgstr_w(text));
|
2015-08-05 03:23:32 +02:00
|
|
|
SysFreeString(key);
|
|
|
|
SysFreeString(text);
|
2015-08-05 03:23:43 +02:00
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
wsprintfW(buf, L"%s: %s", expect[i].key, expect[i].value);
|
2020-02-12 00:32:48 +01:00
|
|
|
ok(wcsstr(all, buf) != NULL, "AllResponseHeaders(%s) don't have expected substr(%s)\n",
|
|
|
|
wine_dbgstr_w(all), wine_dbgstr_w(buf));
|
2015-08-05 03:23:32 +02:00
|
|
|
}
|
2020-02-12 00:32:48 +01:00
|
|
|
|
|
|
|
SysFreeString(all);
|
2015-08-05 03:23:32 +02:00
|
|
|
}
|
|
|
|
|
2015-12-25 08:30:06 +01:00
|
|
|
static void test_illegal_xml(IXMLDOMDocument *xmldom)
|
|
|
|
{
|
|
|
|
IXMLDOMNode *first, *last;
|
|
|
|
VARIANT variant;
|
|
|
|
HRESULT hres;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
hres = IXMLDOMDocument_get_baseName(xmldom, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "Expect E_INVALIDARG, got %08x\n", hres);
|
|
|
|
hres = IXMLDOMDocument_get_baseName(xmldom, &bstr);
|
|
|
|
ok(hres == S_FALSE, "get_baseName failed: %08x\n", hres);
|
|
|
|
ok(bstr == NULL, "bstr(%p): %s\n", bstr, wine_dbgstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
|
|
|
hres = IXMLDOMDocument_get_dataType(xmldom, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "Expect E_INVALIDARG, got %08x\n", hres);
|
|
|
|
hres = IXMLDOMDocument_get_dataType(xmldom, &variant);
|
|
|
|
ok(hres == S_FALSE, "get_dataType failed: %08x\n", hres);
|
2019-12-17 15:54:38 +01:00
|
|
|
ok(V_VT(&variant) == VT_NULL, "got %s\n", wine_dbgstr_variant(&variant));
|
2015-12-25 08:30:06 +01:00
|
|
|
VariantClear(&variant);
|
|
|
|
|
|
|
|
hres = IXMLDOMDocument_get_text(xmldom, &bstr);
|
2020-02-12 00:32:48 +01:00
|
|
|
ok(!lstrcmpW(bstr, L""), "text = %s\n", wine_dbgstr_w(bstr));
|
2015-12-25 08:30:06 +01:00
|
|
|
SysFreeString(bstr);
|
|
|
|
|
|
|
|
hres = IXMLDOMDocument_get_firstChild(xmldom, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "Expect E_INVALIDARG, got %08x\n", hres);
|
|
|
|
|
|
|
|
first = (void*)0xdeadbeef;
|
|
|
|
hres = IXMLDOMDocument_get_firstChild(xmldom, &first);
|
|
|
|
ok(hres == S_FALSE, "get_firstChild failed: %08x\n", hres);
|
|
|
|
ok(first == NULL, "first != NULL\n");
|
|
|
|
|
|
|
|
last = (void*)0xdeadbeef;
|
|
|
|
hres = IXMLDOMDocument_get_lastChild(xmldom, &last);
|
|
|
|
ok(hres == S_FALSE, "get_lastChild failed: %08x\n", hres);
|
|
|
|
ok(last == NULL, "last != NULL\n");
|
|
|
|
}
|
|
|
|
|
2016-02-24 18:53:10 +01:00
|
|
|
#define set_request_header(a,b,c) _set_request_header(__LINE__,a,b,c)
|
2020-02-12 00:32:49 +01:00
|
|
|
static void _set_request_header(unsigned line, IHTMLXMLHttpRequest *xhr, const WCHAR *header_w, const WCHAR *value_w)
|
2016-02-24 18:53:10 +01:00
|
|
|
{
|
2020-02-12 00:32:49 +01:00
|
|
|
BSTR header = SysAllocString(header_w), value = SysAllocString(value_w);
|
2016-02-24 18:53:10 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_setRequestHeader(xhr, header, value);
|
|
|
|
ok_(__FILE__,line)(hres == S_OK, "setRequestHeader failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SysFreeString(header);
|
|
|
|
SysFreeString(value);
|
|
|
|
}
|
|
|
|
|
2020-02-12 00:32:48 +01:00
|
|
|
static void test_responseXML(const WCHAR *expect_text)
|
2015-12-25 08:30:06 +01:00
|
|
|
{
|
|
|
|
IDispatch *disp;
|
|
|
|
IXMLDOMDocument *xmldom;
|
|
|
|
IObjectSafety *safety;
|
|
|
|
DWORD enabled = 0, supported = 0;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
disp = NULL;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_responseXML(xhr, &disp);
|
|
|
|
ok(hres == S_OK, "get_responseXML failed: %08x\n", hres);
|
|
|
|
ok(disp != NULL, "disp == NULL\n");
|
|
|
|
|
|
|
|
xmldom = NULL;
|
|
|
|
hres = IDispatch_QueryInterface(disp, &IID_IXMLDOMDocument, (void**)&xmldom);
|
|
|
|
ok(hres == S_OK, "QueryInterface(IXMLDOMDocument) failed: %08x\n", hres);
|
|
|
|
ok(xmldom != NULL, "xmldom == NULL\n");
|
|
|
|
|
|
|
|
hres = IXMLDOMDocument_QueryInterface(xmldom, &IID_IObjectSafety, (void**)&safety);
|
|
|
|
ok(hres == S_OK, "QueryInterface IObjectSafety failed: %08x\n", hres);
|
|
|
|
hres = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled);
|
|
|
|
ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
ok(broken(supported == (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA)) ||
|
|
|
|
supported == (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER) /* msxml3 SP8+ */,
|
|
|
|
"Expected supported: (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), got %08x\n", supported);
|
2016-03-23 10:31:14 +01:00
|
|
|
ok(enabled == ((INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER) & supported),
|
2015-12-25 08:30:06 +01:00
|
|
|
"Expected enabled: (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), got 0x%08x\n", enabled);
|
|
|
|
IObjectSafety_Release(safety);
|
|
|
|
|
|
|
|
if(!expect_text)
|
|
|
|
test_illegal_xml(xmldom);
|
|
|
|
|
|
|
|
IXMLDOMDocument_Release(xmldom);
|
|
|
|
IDispatch_Release(disp);
|
|
|
|
}
|
|
|
|
|
2016-04-07 15:33:44 +02:00
|
|
|
#define xhr_open(a,b) _xhr_open(__LINE__,a,b)
|
2020-02-12 00:32:49 +01:00
|
|
|
static HRESULT _xhr_open(unsigned line, const WCHAR *url_w, const WCHAR *method_w)
|
2016-04-07 15:33:44 +02:00
|
|
|
{
|
2020-02-12 00:32:49 +01:00
|
|
|
BSTR method = SysAllocString(method_w);
|
|
|
|
BSTR url = SysAllocString(url_w);
|
2016-04-07 15:33:44 +02:00
|
|
|
VARIANT async, empty;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
V_VT(&async) = VT_BOOL;
|
|
|
|
V_BOOL(&async) = VARIANT_TRUE;
|
|
|
|
V_VT(&empty) = VT_EMPTY;
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_open(xhr, method, url, async, empty, empty);
|
|
|
|
ok_(__FILE__,line)(hres == S_OK, "open failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SysFreeString(method);
|
|
|
|
SysFreeString(url);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define test_response_text(a) _test_response_text(__LINE__,a)
|
2020-02-12 00:32:48 +01:00
|
|
|
static void _test_response_text(unsigned line, const WCHAR *expect_text)
|
2016-04-07 15:33:44 +02:00
|
|
|
{
|
|
|
|
BSTR text = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_responseText(xhr, &text);
|
|
|
|
ok(hres == S_OK, "get_responseText failed: %08x\n", hres);
|
|
|
|
ok(text != NULL, "test == NULL\n");
|
|
|
|
if(expect_text) {
|
|
|
|
unsigned len;
|
|
|
|
/* Some recent version of IE strip trailing '\n' from post.php response, while others don't. */
|
|
|
|
len = SysStringLen(text);
|
|
|
|
if(text[len-1] == '\n')
|
|
|
|
text[len-1] = 0;
|
2020-02-12 00:32:48 +01:00
|
|
|
ok_(__FILE__,line)(!lstrcmpW(text, expect_text), "expect %s, got %s\n",
|
|
|
|
wine_dbgstr_w(expect_text), wine_dbgstr_w(text));
|
2016-04-07 15:33:44 +02:00
|
|
|
}
|
|
|
|
SysFreeString(text);
|
|
|
|
}
|
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
static void test_sync_xhr(IHTMLDocument2 *doc, const WCHAR *xml_url, const WCHAR *expect_text)
|
2015-06-25 14:16:53 +02:00
|
|
|
{
|
|
|
|
VARIANT vbool, vempty, var;
|
|
|
|
BSTR method, url;
|
|
|
|
BSTR text;
|
|
|
|
LONG val;
|
|
|
|
HRESULT hres;
|
2015-08-05 03:23:32 +02:00
|
|
|
static const struct HEADER_TYPE expect_headers[] = {
|
2020-02-12 00:32:49 +01:00
|
|
|
{L"Content-Length", L"51"},
|
|
|
|
{L"Content-Type", L"application/xml"}
|
2015-08-05 03:23:32 +02:00
|
|
|
};
|
2015-06-25 14:16:53 +02:00
|
|
|
|
2015-12-25 08:30:06 +01:00
|
|
|
trace("test_sync_xhr\n");
|
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
create_xmlhttprequest(doc);
|
|
|
|
if(!xhr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
V_VT(&var) = VT_EMPTY;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_onreadystatechange(xhr, &var);
|
|
|
|
ok(hres == S_OK, "get_onreadystatechange failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&var) == VT_NULL, "V_VT(onreadystatechange) = %d\n", V_VT(&var));
|
|
|
|
|
|
|
|
V_VT(&var) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(&var) = (IDispatch*)&xmlhttprequest_onreadystatechange_obj;
|
|
|
|
hres = IHTMLXMLHttpRequest_put_onreadystatechange(xhr, var);
|
|
|
|
ok(hres == S_OK, "put_onreadystatechange failed: %08x\n", hres);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_EMPTY;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_onreadystatechange(xhr, &var);
|
|
|
|
ok(hres == S_OK, "get_onreadystatechange failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH, "V_VT(onreadystatechange) = %d\n", V_VT(&var));
|
|
|
|
ok(V_DISPATCH(&var) == (IDispatch*)&xmlhttprequest_onreadystatechange_obj, "unexpected onreadystatechange value\n");
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_readyState(xhr, NULL);
|
2015-06-30 15:53:20 +02:00
|
|
|
ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
|
2015-06-30 15:53:20 +02:00
|
|
|
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
|
|
|
|
ok(val == 0, "Expect UNSENT, got %d\n", val);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_status(xhr, NULL);
|
2015-07-22 17:34:05 +02:00
|
|
|
ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
|
2015-07-22 17:34:05 +02:00
|
|
|
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
|
|
|
|
ok(val == 0, "Expect 0, got %d\n", val);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_statusText(xhr, NULL);
|
2015-08-05 03:21:57 +02:00
|
|
|
ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
|
2015-08-05 03:21:57 +02:00
|
|
|
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
|
|
|
|
ok(text == NULL, "Expect NULL, got %p\n", text);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
2015-08-05 03:23:43 +02:00
|
|
|
text = (BSTR)0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text);
|
|
|
|
ok(hres == E_FAIL, "got %08x\n", hres);
|
|
|
|
ok(text == NULL, "text = %p\n", text);
|
|
|
|
|
2015-08-05 03:23:32 +02:00
|
|
|
text = (BSTR)0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text);
|
|
|
|
ok(hres == E_FAIL, "got %08x\n", hres);
|
|
|
|
ok(text == NULL, "text = %p\n", text);
|
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
method = SysAllocString(L"GET");
|
|
|
|
url = SysAllocString(xml_url);
|
2015-06-25 14:16:53 +02:00
|
|
|
V_VT(&vbool) = VT_BOOL;
|
|
|
|
V_BOOL(&vbool) = VARIANT_FALSE;
|
|
|
|
V_VT(&vempty) = VT_EMPTY;
|
|
|
|
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
hres = IHTMLXMLHttpRequest_open(xhr, method, url, vbool, vempty, vempty);
|
|
|
|
todo_wine ok(hres == S_OK, "open failed: %08x\n", hres); /* Gecko 30+ only supports async */
|
|
|
|
todo_wine CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
|
|
|
|
SysFreeString(method);
|
|
|
|
SysFreeString(url);
|
|
|
|
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IHTMLXMLHttpRequest_Release(xhr);
|
|
|
|
xhr = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-05 03:23:43 +02:00
|
|
|
text = (BSTR)0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text);
|
|
|
|
ok(hres == E_FAIL, "got %08x\n", hres);
|
|
|
|
ok(text == NULL, "text = %p\n", text);
|
|
|
|
|
2015-08-05 03:23:32 +02:00
|
|
|
text = (BSTR)0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text);
|
|
|
|
ok(hres == E_FAIL, "got %08x\n", hres);
|
|
|
|
ok(text == NULL, "text = %p\n", text);
|
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
|
|
|
|
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
|
|
|
|
ok(val == 0, "Expect 0, got %d\n", val);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
|
|
|
|
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
|
|
|
|
ok(text == NULL, "Expect NULL, got %p\n", text);
|
|
|
|
|
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
|
|
|
|
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
|
|
|
|
ok(val == 1, "Expect OPENED, got %d\n", val);
|
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
set_request_header(xhr, L"x-wine-test", L"sync-test");
|
2016-02-24 18:53:10 +01:00
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_loading);
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_done);
|
2015-08-19 03:33:41 +02:00
|
|
|
loading_cnt = 0;
|
2015-06-25 14:16:53 +02:00
|
|
|
hres = IHTMLXMLHttpRequest_send(xhr, vempty);
|
|
|
|
ok(hres == S_OK, "send failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_headers_received);
|
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_loading);
|
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_done);
|
2015-08-19 03:33:41 +02:00
|
|
|
ok(loading_cnt == 1, "loading_cnt = %d\n", loading_cnt);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
2015-08-05 03:23:32 +02:00
|
|
|
text = NULL;
|
|
|
|
hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text);
|
|
|
|
ok(hres == S_OK, "getResponseHeader failed, got %08x\n", hres);
|
|
|
|
ok(text != NULL, "text == NULL\n");
|
|
|
|
SysFreeString(text);
|
|
|
|
|
2015-08-19 03:33:41 +02:00
|
|
|
if(expect_text)
|
2018-06-07 23:44:40 +02:00
|
|
|
test_header(expect_headers, ARRAY_SIZE(expect_headers));
|
2015-08-05 03:23:32 +02:00
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
|
|
|
|
ok(hres == S_OK, "get_status failed: %08x\n", hres);
|
|
|
|
ok(val == 200, "Expect 200, got %d\n", val);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
|
|
|
|
ok(hres == S_OK, "get_statusText failed: %08x\n", hres);
|
|
|
|
ok(text != NULL, "text == NULL\n");
|
2020-02-12 00:32:48 +01:00
|
|
|
ok(!lstrcmpW(text, L"OK"),
|
2015-06-25 14:16:53 +02:00
|
|
|
"Expected \"OK\", got %s\n", wine_dbgstr_w(text));
|
|
|
|
SysFreeString(text);
|
|
|
|
|
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
|
|
|
|
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
|
|
|
|
ok(val == 4, "Expect DONE, got %d\n", val);
|
|
|
|
|
2016-04-07 15:33:44 +02:00
|
|
|
test_response_text(expect_text);
|
2015-12-25 08:30:06 +01:00
|
|
|
test_responseXML(expect_text);
|
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
IHTMLXMLHttpRequest_Release(xhr);
|
|
|
|
xhr = NULL;
|
|
|
|
}
|
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
static void test_async_xhr(IHTMLDocument2 *doc, const WCHAR *xml_url, const WCHAR *expect_text)
|
2015-06-25 14:16:53 +02:00
|
|
|
{
|
2016-04-07 15:33:44 +02:00
|
|
|
VARIANT var, vempty;
|
2015-06-25 14:16:53 +02:00
|
|
|
BSTR text;
|
|
|
|
LONG val;
|
|
|
|
HRESULT hres;
|
2015-08-05 03:23:32 +02:00
|
|
|
static const struct HEADER_TYPE expect_headers[] = {
|
2020-02-12 00:32:49 +01:00
|
|
|
{L"Content-Length", L"51"},
|
|
|
|
{L"Content-Type", L"application/xml"}
|
2015-08-05 03:23:32 +02:00
|
|
|
};
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
create_xmlhttprequest(doc);
|
|
|
|
if(!xhr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
V_VT(&var) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(&var) = (IDispatch*)&xmlhttprequest_onreadystatechange_obj;
|
|
|
|
hres = IHTMLXMLHttpRequest_put_onreadystatechange(xhr, var);
|
|
|
|
ok(hres == S_OK, "put_onreadystatechange failed: %08x\n", hres);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_EMPTY;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_onreadystatechange(xhr, &var);
|
|
|
|
ok(hres == S_OK, "get_onreadystatechange failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH, "V_VT(onreadystatechange) = %d\n", V_VT(&var));
|
|
|
|
ok(V_DISPATCH(&var) == (IDispatch*)&xmlhttprequest_onreadystatechange_obj, "unexpected onreadystatechange value\n");
|
|
|
|
|
2015-08-05 03:23:32 +02:00
|
|
|
hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, NULL, &text);
|
|
|
|
ok(hres == E_INVALIDARG, "Expect E_INVALIDARG, got %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, NULL);
|
|
|
|
ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, NULL, NULL);
|
|
|
|
ok(hres == E_POINTER || broken(hres == E_INVALIDARG), /* Vista and before */
|
|
|
|
"Expect E_POINTER, got %08x\n", hres);
|
|
|
|
|
|
|
|
text = (BSTR)0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text);
|
|
|
|
ok(hres == E_FAIL, "got %08x\n", hres);
|
|
|
|
ok(text == NULL, "text = %p\n", text);
|
|
|
|
|
2015-08-05 03:23:43 +02:00
|
|
|
hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, NULL);
|
|
|
|
ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
|
|
|
|
|
|
|
|
text = (BSTR)0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text);
|
|
|
|
ok(hres == E_FAIL, "got %08x\n", hres);
|
|
|
|
ok(text == NULL, "text = %p\n", text);
|
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
|
2015-07-22 17:34:05 +02:00
|
|
|
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
|
|
|
|
ok(val == 0, "Expect 0, got %d\n", val);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
2015-06-29 10:05:30 +02:00
|
|
|
text = (BSTR)0xdeadbeef;
|
2015-06-25 14:16:53 +02:00
|
|
|
hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
|
2015-08-05 03:21:57 +02:00
|
|
|
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
|
|
|
|
ok(text == NULL, "Expect NULL, got %p\n", text);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
|
2015-06-30 15:53:20 +02:00
|
|
|
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
|
|
|
|
ok(val == 0, "Expect UNSENT, got %d\n", val);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
2020-02-12 00:32:49 +01:00
|
|
|
hres = xhr_open(xml_url, L"GET");
|
2015-07-01 17:38:17 +02:00
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IHTMLXMLHttpRequest_Release(xhr);
|
|
|
|
xhr = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-05 03:23:43 +02:00
|
|
|
text = (BSTR)0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text);
|
|
|
|
ok(hres == E_FAIL, "got %08x\n", hres);
|
|
|
|
ok(text == NULL, "text = %p\n", text);
|
|
|
|
|
2015-08-05 03:23:32 +02:00
|
|
|
text = (BSTR)0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text);
|
|
|
|
ok(hres == E_FAIL, "got %08x\n", hres);
|
|
|
|
ok(text == NULL, "text = %p\n", text);
|
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
|
2015-07-22 17:34:05 +02:00
|
|
|
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
|
|
|
|
ok(val == 0, "Expect 0, got %d\n", val);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
|
2015-08-05 03:21:57 +02:00
|
|
|
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
|
|
|
|
ok(text == NULL, "Expect NULL, got %p\n", text);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
|
2015-06-30 15:53:20 +02:00
|
|
|
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
|
|
|
|
ok(val == 1, "Expect OPENED, got %d\n", val);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
set_request_header(xhr, L"x-wine-test", L"async-test");
|
2016-02-24 18:53:10 +01:00
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_loading);
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_done);
|
2015-08-19 03:33:41 +02:00
|
|
|
loading_cnt = 0;
|
2016-04-07 15:33:44 +02:00
|
|
|
V_VT(&vempty) = VT_EMPTY;
|
2015-06-25 14:16:53 +02:00
|
|
|
hres = IHTMLXMLHttpRequest_send(xhr, vempty);
|
|
|
|
|
2015-07-07 16:49:58 +02:00
|
|
|
ok(hres == S_OK, "send failed: %08x\n", hres);
|
2015-06-30 15:51:21 +02:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
pump_msgs(&called_xmlhttprequest_onreadystatechange_done);
|
2015-06-25 14:16:53 +02:00
|
|
|
todo_wine CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
|
2015-07-07 16:49:58 +02:00
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_headers_received);
|
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_loading);
|
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_done);
|
2015-08-19 03:33:41 +02:00
|
|
|
/* Workaround for loading large files */
|
2016-02-17 21:55:03 +01:00
|
|
|
todo_wine_if(!expect_text)
|
2015-08-19 03:33:41 +02:00
|
|
|
ok(loading_cnt == 1, "loading_cnt = %d\n", loading_cnt);
|
2015-06-30 15:51:21 +02:00
|
|
|
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IHTMLXMLHttpRequest_Release(xhr);
|
|
|
|
xhr = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2015-06-25 14:16:53 +02:00
|
|
|
|
2015-08-05 03:23:43 +02:00
|
|
|
text = NULL;
|
|
|
|
hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text);
|
|
|
|
ok(hres == S_OK, "getAllResponseHeader failed, got %08x\n", hres);
|
|
|
|
ok(text != NULL, "text == NULL\n");
|
|
|
|
SysFreeString(text);
|
|
|
|
|
2015-08-19 03:33:41 +02:00
|
|
|
if(expect_text)
|
2018-06-07 23:44:40 +02:00
|
|
|
test_header(expect_headers, ARRAY_SIZE(expect_headers));
|
2015-08-05 03:23:32 +02:00
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
|
2015-07-22 17:34:05 +02:00
|
|
|
ok(hres == S_OK, "get_status failed: %08x\n", hres);
|
|
|
|
ok(val == 200, "Expect 200, got %d\n", val);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
2015-07-07 16:49:58 +02:00
|
|
|
text = NULL;
|
2015-06-25 14:16:53 +02:00
|
|
|
hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
|
2015-08-05 03:21:57 +02:00
|
|
|
ok(hres == S_OK, "get_statusText failed: %08x\n", hres);
|
|
|
|
ok(text != NULL, "text == NULL\n");
|
2020-02-12 00:32:48 +01:00
|
|
|
ok(!lstrcmpW(text, L"OK"), "Expected \"OK\", got %s\n", wine_dbgstr_w(text));
|
2015-06-25 14:16:53 +02:00
|
|
|
SysFreeString(text);
|
|
|
|
|
|
|
|
val = 0xdeadbeef;
|
|
|
|
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
|
|
|
|
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
|
2015-07-07 16:49:58 +02:00
|
|
|
ok(val == 4, "Expect DONE, got %d\n", val);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
2016-04-07 15:33:44 +02:00
|
|
|
test_response_text(expect_text);
|
2015-12-25 08:30:06 +01:00
|
|
|
test_responseXML(expect_text);
|
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
IHTMLXMLHttpRequest_Release(xhr);
|
|
|
|
xhr = NULL;
|
|
|
|
}
|
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
static void test_async_xhr_abort(IHTMLDocument2 *doc, const WCHAR *xml_url)
|
2015-08-19 03:33:41 +02:00
|
|
|
{
|
2016-04-07 15:33:44 +02:00
|
|
|
VARIANT vempty, var;
|
2015-08-19 03:33:41 +02:00
|
|
|
LONG val;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
V_VT(&vempty) = VT_EMPTY;
|
|
|
|
|
|
|
|
trace("abort before send() is fired\n");
|
|
|
|
create_xmlhttprequest(doc);
|
2015-08-22 15:18:16 +02:00
|
|
|
if(!xhr)
|
|
|
|
return;
|
|
|
|
|
2015-08-19 03:33:41 +02:00
|
|
|
V_VT(&var) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(&var) = (IDispatch*)&xmlhttprequest_onreadystatechange_obj;
|
|
|
|
hres = IHTMLXMLHttpRequest_put_onreadystatechange(xhr, var);
|
|
|
|
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
2020-02-12 00:32:49 +01:00
|
|
|
xhr_open(xml_url, L"GET");
|
2015-08-19 03:33:41 +02:00
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_abort(xhr);
|
|
|
|
ok(hres == S_OK, "abort failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
|
|
|
|
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
|
|
|
|
ok(val == 0, "Expect 0, got %d\n", val);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
|
|
|
|
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
|
|
|
|
ok(val == 0, "Expect UNSENT, got %d\n", val);
|
|
|
|
|
|
|
|
IHTMLXMLHttpRequest_Release(xhr);
|
|
|
|
xhr = NULL;
|
|
|
|
|
|
|
|
trace("abort after send() is fired\n");
|
|
|
|
create_xmlhttprequest(doc);
|
|
|
|
V_VT(&var) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(&var) = (IDispatch*)&xmlhttprequest_onreadystatechange_obj;
|
|
|
|
hres = IHTMLXMLHttpRequest_put_onreadystatechange(xhr, var);
|
|
|
|
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
2020-02-12 00:32:49 +01:00
|
|
|
xhr_open(xml_url, L"GET");
|
2015-08-19 03:33:41 +02:00
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
|
|
|
|
loading_cnt = 0;
|
|
|
|
readystatechange_cnt = 0;
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_done);
|
|
|
|
hres = IHTMLXMLHttpRequest_send(xhr, vempty);
|
|
|
|
ok(hres == S_OK, "send failed: %08x\n", hres);
|
|
|
|
todo_wine CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_abort(xhr);
|
|
|
|
ok(hres == S_OK, "abort failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_done);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
|
|
|
|
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
|
|
|
|
ok(val == 0, "Expect UNSENT, got %d\n", val);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_get_status(xhr, &val);
|
|
|
|
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
|
|
|
|
ok(val == 0, "Expect 0, got %d\n", val);
|
|
|
|
|
|
|
|
ok(loading_cnt == 0, "loading_cnt = %d, expect 0, loading_cnt\n", loading_cnt);
|
|
|
|
todo_wine ok(readystatechange_cnt == 2, "readystatechange_cnt = %d, expect 2\n", readystatechange_cnt);
|
|
|
|
|
|
|
|
IHTMLXMLHttpRequest_Release(xhr);
|
|
|
|
xhr = NULL;
|
2016-04-07 15:33:44 +02:00
|
|
|
}
|
2015-08-19 03:33:41 +02:00
|
|
|
|
2016-04-07 15:33:44 +02:00
|
|
|
static void test_xhr_post(IHTMLDocument2 *doc)
|
|
|
|
{
|
|
|
|
VARIANT v;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
trace("send string...\n");
|
|
|
|
|
|
|
|
create_xmlhttprequest(doc);
|
|
|
|
if(!xhr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
V_VT(&v) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(&v) = (IDispatch*)&xmlhttprequest_onreadystatechange_obj;
|
|
|
|
hres = IHTMLXMLHttpRequest_put_onreadystatechange(xhr, v);
|
|
|
|
ok(hres == S_OK, "put_onreadystatechange failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
2020-02-12 00:32:49 +01:00
|
|
|
xhr_open(L"http://test.winehq.org/tests/post.php", L"POST");
|
2016-04-07 15:33:44 +02:00
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
set_request_header(xhr, L"Content-Type", L"application/x-www-form-urlencoded");
|
2016-04-07 15:33:44 +02:00
|
|
|
|
|
|
|
V_VT(&v) = VT_BSTR;
|
2020-02-12 00:32:49 +01:00
|
|
|
V_BSTR(&v) = SysAllocString(L"X=Testing");
|
2016-04-07 15:33:44 +02:00
|
|
|
|
|
|
|
loading_cnt = 0;
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_loading);
|
|
|
|
SET_EXPECT(xmlhttprequest_onreadystatechange_done);
|
|
|
|
|
|
|
|
hres = IHTMLXMLHttpRequest_send(xhr, v);
|
|
|
|
ok(hres == S_OK, "send failed: %08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
pump_msgs(&called_xmlhttprequest_onreadystatechange_done);
|
|
|
|
|
|
|
|
todo_wine CHECK_CALLED(xmlhttprequest_onreadystatechange_opened);
|
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_headers_received);
|
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_loading);
|
|
|
|
CHECK_CALLED(xmlhttprequest_onreadystatechange_done);
|
|
|
|
ok(loading_cnt == 1, "loading_cnt = %d\n", loading_cnt);
|
|
|
|
|
|
|
|
SysFreeString(V_BSTR(&v));
|
|
|
|
|
2020-02-12 00:32:48 +01:00
|
|
|
test_response_text(L"X => Testing");
|
2016-04-07 15:33:44 +02:00
|
|
|
|
|
|
|
IHTMLXMLHttpRequest_Release(xhr);
|
|
|
|
xhr = NULL;
|
2015-08-19 03:33:41 +02:00
|
|
|
}
|
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
static IHTMLDocument2 *create_doc_from_url(const WCHAR *start_url)
|
2015-06-25 14:16:53 +02:00
|
|
|
{
|
|
|
|
BSTR url;
|
|
|
|
IBindCtx *bc;
|
|
|
|
IMoniker *url_mon;
|
|
|
|
IPersistMoniker *persist_mon;
|
|
|
|
IHTMLDocument2 *doc;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CreateBindCtx(0, &bc);
|
|
|
|
ok(hres == S_OK, "CreateBindCtx failed: 0x%08x\n", hres);
|
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
url = SysAllocString(start_url);
|
2015-06-25 14:16:53 +02:00
|
|
|
hres = CreateURLMoniker(NULL, url, &url_mon);
|
|
|
|
ok(hres == S_OK, "CreateURLMoniker failed: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_HTMLDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, &IID_IHTMLDocument2,
|
|
|
|
(void**)&doc);
|
2020-05-13 10:33:54 +02:00
|
|
|
#if !defined(__i386__) && !defined(__x86_64__)
|
|
|
|
todo_wine
|
|
|
|
#endif
|
2015-06-25 14:16:53 +02:00
|
|
|
ok(hres == S_OK, "CoCreateInstance failed: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistMoniker,
|
|
|
|
(void**)&persist_mon);
|
|
|
|
ok(hres == S_OK, "IHTMLDocument2_QueryInterface failed: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
hres = IPersistMoniker_Load(persist_mon, FALSE, url_mon, bc,
|
|
|
|
STGM_SHARE_EXCLUSIVE | STGM_READWRITE);
|
|
|
|
ok(hres == S_OK, "IPersistMoniker_Load failed: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
IPersistMoniker_Release(persist_mon);
|
|
|
|
IMoniker_Release(url_mon);
|
|
|
|
IBindCtx_Release(bc);
|
|
|
|
SysFreeString(url);
|
|
|
|
|
2015-07-07 16:49:42 +02:00
|
|
|
doc_complete = FALSE;
|
|
|
|
notif_doc = doc;
|
|
|
|
do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
|
|
|
|
pump_msgs(&doc_complete);
|
|
|
|
|
2015-06-25 14:16:53 +02:00
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(xmlhttprequest)
|
|
|
|
{
|
|
|
|
IHTMLDocument2 *doc;
|
2020-02-12 00:32:49 +01:00
|
|
|
static const WCHAR start_url[] = L"http://test.winehq.org/tests/hello.html";
|
|
|
|
static const WCHAR xml_url[] = L"http://test.winehq.org/tests/xmltest.xml";
|
|
|
|
static const WCHAR large_page_url[] = L"http://test.winehq.org/tests/data.php";
|
2020-02-12 00:32:48 +01:00
|
|
|
static const WCHAR expect_response_text[] = L"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>";
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2020-02-12 00:32:49 +01:00
|
|
|
content_type = SysAllocString(L"Content-Type");
|
2015-06-25 14:16:53 +02:00
|
|
|
doc = create_doc_from_url(start_url);
|
|
|
|
if(doc) {
|
2015-08-19 03:33:41 +02:00
|
|
|
test_sync_xhr(doc, xml_url, expect_response_text);
|
|
|
|
test_sync_xhr(doc, large_page_url, NULL);
|
|
|
|
test_async_xhr(doc, xml_url, expect_response_text);
|
|
|
|
test_async_xhr(doc, large_page_url, NULL);
|
|
|
|
test_async_xhr_abort(doc, large_page_url);
|
2016-04-07 15:33:44 +02:00
|
|
|
test_xhr_post(doc);
|
2015-06-25 14:16:53 +02:00
|
|
|
IHTMLDocument2_Release(doc);
|
|
|
|
}
|
2015-08-05 03:23:32 +02:00
|
|
|
SysFreeString(content_type);
|
2015-06-25 14:16:53 +02:00
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|