msxml3: Try mshtml container url as a base for relative request url.

This commit is contained in:
Nikolay Sivov 2012-01-11 05:19:48 +03:00 committed by Alexandre Julliard
parent fd4afaf639
commit 9b1f217c41
4 changed files with 64 additions and 5 deletions

View File

@ -33,10 +33,16 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wingdi.h"
#include "wininet.h"
#include "winreg.h"
#include "winuser.h" #include "winuser.h"
#include "ole2.h" #include "ole2.h"
#include "mshtml.h"
#include "msxml6.h" #include "msxml6.h"
#include "objsafe.h" #include "objsafe.h"
#include "docobj.h"
#include "shlwapi.h"
#include "msxml_private.h" #include "msxml_private.h"
@ -72,6 +78,7 @@ typedef struct
/* request */ /* request */
BINDVERB verb; BINDVERB verb;
BSTR custom; BSTR custom;
BSTR siteurl;
BSTR url; BSTR url;
BOOL async; BOOL async;
struct list reqheaders; struct list reqheaders;
@ -767,6 +774,7 @@ static ULONG WINAPI httprequest_Release(IXMLHTTPRequest *iface)
IUnknown_Release( This->site ); IUnknown_Release( This->site );
SysFreeString(This->custom); SysFreeString(This->custom);
SysFreeString(This->siteurl);
SysFreeString(This->url); SysFreeString(This->url);
SysFreeString(This->user); SysFreeString(This->user);
SysFreeString(This->password); SysFreeString(This->password);
@ -906,7 +914,22 @@ static HRESULT WINAPI httprequest_open(IXMLHTTPRequest *iface, BSTR method, BSTR
return E_FAIL; return E_FAIL;
} }
This->url = SysAllocString(url); /* try to combine with site url */
if (This->siteurl && PathIsRelativeW(url))
{
DWORD len = INTERNET_MAX_URL_LENGTH;
WCHAR *fullW = heap_alloc(len*sizeof(WCHAR));
hr = UrlCombineW(This->siteurl, url, fullW, &len, 0);
if (hr == S_OK)
{
TRACE("combined url %s\n", debugstr_w(fullW));
This->url = SysAllocString(fullW);
}
heap_free(fullW);
}
else
This->url = SysAllocString(url);
VariantInit(&is_async); VariantInit(&is_async);
hr = VariantChangeType(&is_async, &async, 0, VT_BOOL); hr = VariantChangeType(&is_async, &async, 0, VT_BOOL);
@ -1324,6 +1347,8 @@ static HRESULT WINAPI httprequest_ObjectWithSite_GetSite( IObjectWithSite *iface
static HRESULT WINAPI httprequest_ObjectWithSite_SetSite( IObjectWithSite *iface, IUnknown *punk ) static HRESULT WINAPI httprequest_ObjectWithSite_SetSite( IObjectWithSite *iface, IUnknown *punk )
{ {
httprequest *This = impl_from_IObjectWithSite(iface); httprequest *This = impl_from_IObjectWithSite(iface);
IServiceProvider *provider;
HRESULT hr;
TRACE("(%p)->(%p)\n", iface, punk); TRACE("(%p)->(%p)\n", iface, punk);
@ -1335,6 +1360,23 @@ static HRESULT WINAPI httprequest_ObjectWithSite_SetSite( IObjectWithSite *iface
This->site = punk; This->site = punk;
hr = IUnknown_QueryInterface(This->site, &IID_IServiceProvider, (void**)&provider);
if (hr == S_OK)
{
IHTMLDocument2 *doc;
hr = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc);
if (hr == S_OK)
{
SysFreeString(This->siteurl);
hr = IHTMLDocument2_get_URL(doc, &This->siteurl);
IHTMLDocument2_Release(doc);
TRACE("host url %s, 0x%08x\n", debugstr_w(This->siteurl), hr);
}
IServiceProvider_Release(provider);
}
return S_OK; return S_OK;
} }
@ -1426,7 +1468,7 @@ HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, void **ppObj)
req->async = FALSE; req->async = FALSE;
req->verb = -1; req->verb = -1;
req->custom = NULL; req->custom = NULL;
req->url = req->user = req->password = NULL; req->url = req->siteurl = req->user = req->password = NULL;
req->state = READYSTATE_UNINITIALIZED; req->state = READYSTATE_UNINITIALIZED;
req->sink = NULL; req->sink = NULL;

View File

@ -5000,11 +5000,11 @@ todo_wine {
hr = IObjectWithSite_SetSite(obj_site, &testsite.IUnknown_iface); hr = IObjectWithSite_SetSite(obj_site, &testsite.IUnknown_iface);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
todo_wine{
CHECK_CALLED(site_qi_IServiceProvider); CHECK_CALLED(site_qi_IServiceProvider);
todo_wine
CHECK_CALLED(sp_queryservice_SID_SBindHost); CHECK_CALLED(sp_queryservice_SID_SBindHost);
CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2); CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2);
todo_wine {
CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2); CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2);
CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc); CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc);
/* this one isn't very reliable /* this one isn't very reliable
@ -5019,11 +5019,23 @@ todo_wine{
} }
IObjectWithSite_Release(obj_site); IObjectWithSite_Release(obj_site);
/* try to set site another time */
/* to be removed once IObjectWithSite is properly separated */
SET_EXPECT(site_qi_IServiceProvider);
SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2);
hr = IObjectWithSite_SetSite(obj_site2, &testsite.IUnknown_iface);
EXPECT_HR(hr, S_OK);
todo_wine EXPECT_REF(xhr, 1); todo_wine EXPECT_REF(xhr, 1);
IXMLHttpRequest_Release(xhr); IXMLHttpRequest_Release(xhr);
/* still works after request is released */ /* still works after request is released */
/* to be removed once IObjectWithSite is properly separated */
SET_EXPECT(site_qi_IServiceProvider); SET_EXPECT(site_qi_IServiceProvider);
SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2);
hr = IObjectWithSite_SetSite(obj_site2, &testsite.IUnknown_iface); hr = IObjectWithSite_SetSite(obj_site2, &testsite.IUnknown_iface);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);

View File

@ -126,7 +126,7 @@ DEFINE_GUID(CLSID_TF_DisplayAttributeMgr, 0x3ce74de4,0x53d3,0x4d74,0x8b,0x83,0x4
DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD, 0x34745c63,0xb2f0,0x4784,0x8b,0x67,0x5e,0x12,0xc8,0x70,0x1a,0x31); DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD, 0x34745c63,0xb2f0,0x4784,0x8b,0x67,0x5e,0x12,0xc8,0x70,0x1a,0x31);
DEFINE_GUID(GUID_TFCAT_TIP_SPEECH, 0xB5A73CD1,0x8355,0x426B,0xA1,0x61,0x25,0x98,0x08,0xF2,0x6B,0x14); DEFINE_GUID(GUID_TFCAT_TIP_SPEECH, 0xB5A73CD1,0x8355,0x426B,0xA1,0x61,0x25,0x98,0x08,0xF2,0x6B,0x14);
DEFINE_GUID(GUID_TFCAT_TIP_HANDWRITING, 0x246ecb87,0xc2f2,0x4abe,0x90,0x5b,0xc8,0xb3,0x8a,0xdd,0x2c,0x43); DEFINE_GUID(GUID_TFCAT_TIP_HANDWRITING, 0x246ecb87,0xc2f2,0x4abe,0x90,0x5b,0xc8,0xb3,0x8a,0xdd,0x2c,0x43);
DEFINE_GUID (GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER, 0x046B8C80,0x1647,0x40F7,0x9B,0x21,0xB9,0x3B,0x81,0xAA,0xBC,0x1B); DEFINE_GUID(GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER, 0x046B8C80,0x1647,0x40F7,0x9B,0x21,0xB9,0x3B,0x81,0xAA,0xBC,0x1B);
DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_DISABLED, 0x71a5b253,0x1951,0x466b,0x9f,0xbc,0x9c,0x88,0x08,0xfa,0x84,0xf2); DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_DISABLED, 0x71a5b253,0x1951,0x466b,0x9f,0xbc,0x9c,0x88,0x08,0xfa,0x84,0xf2);
DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE, 0x58273aad,0x01bb,0x4164,0x95,0xc6,0x75,0x5b,0xa0,0xb5,0x16,0x2d); DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE, 0x58273aad,0x01bb,0x4164,0x95,0xc6,0x75,0x5b,0xa0,0xb5,0x16,0x2d);
DEFINE_GUID(GUID_COMPARTMENT_HANDWRITING_OPENCLOSE, 0xf9ae2c6b,0x1866,0x4361,0xaf,0x72,0x7a,0xa3,0x09,0x48,0x89,0x0e); DEFINE_GUID(GUID_COMPARTMENT_HANDWRITING_OPENCLOSE, 0xf9ae2c6b,0x1866,0x4361,0xaf,0x72,0x7a,0xa3,0x09,0x48,0x89,0x0e);
@ -136,3 +136,6 @@ DEFINE_GUID(GUID_COMPARTMENT_SPEECH_GLOBALSTATE, 0x2a54fe8e,0x0d08,0x460c,0xa
DEFINE_GUID(GUID_COMPARTMENT_PERSISTMENUENABLED, 0x575f3783,0x70c8,0x47c8,0xae,0x5d,0x91,0xa0,0x1a,0x1f,0x75,0x92); DEFINE_GUID(GUID_COMPARTMENT_PERSISTMENUENABLED, 0x575f3783,0x70c8,0x47c8,0xae,0x5d,0x91,0xa0,0x1a,0x1f,0x75,0x92);
DEFINE_GUID(GUID_COMPARTMENT_EMPTYCONTEXT, 0xd7487dbf,0x804e,0x41c5,0x89,0x4d,0xad,0x96,0xfd,0x4e,0xea,0x13); DEFINE_GUID(GUID_COMPARTMENT_EMPTYCONTEXT, 0xd7487dbf,0x804e,0x41c5,0x89,0x4d,0xad,0x96,0xfd,0x4e,0xea,0x13);
DEFINE_GUID(GUID_COMPARTMENT_TIPUISTATUS, 0x148ca3ec,0x0366,0x401c,0x8d,0x75,0xed,0x97,0x8d,0x85,0xfb,0xc9); DEFINE_GUID(GUID_COMPARTMENT_TIPUISTATUS, 0x148ca3ec,0x0366,0x401c,0x8d,0x75,0xed,0x97,0x8d,0x85,0xfb,0xc9);
/* service identifiers not declared in headers */
DEFINE_GUID(SID_SContainerDispatch,0xb722be00,0x4e68,0x101b,0xa2,0xbc,0x00,0xaa,0x00,0x40,0x47,0x70);

View File

@ -407,3 +407,5 @@ cpp_quote("#define IID_IMsoDocumentSite IID_IOleDocumentSite")
cpp_quote("#define IID_IMsoView IID_IOleDocumentView") cpp_quote("#define IID_IMsoView IID_IOleDocumentView")
cpp_quote("#define IID_IEnumMsoView IID_IEnumOleDocumentViews") cpp_quote("#define IID_IEnumMsoView IID_IEnumOleDocumentViews")
cpp_quote("#define IID_IMsoCommandTarget IID_IOleCommandTarget") cpp_quote("#define IID_IMsoCommandTarget IID_IOleCommandTarget")
cpp_quote("EXTERN_C const GUID SID_SContainerDispatch;")