jscript: ActiveX objects might not support IServiceProvider Interface.

This commit is contained in:
Alistair Leslie-Hughes 2012-01-23 12:21:23 +11:00 committed by Alexandre Julliard
parent bb4c210888
commit ae46ad83a5
2 changed files with 38 additions and 4 deletions

View file

@ -287,7 +287,12 @@ static ULONG WINAPI AXSite_Release(IServiceProvider *iface)
TRACE("(%p) ref=%d\n", This, ref);
if(!ref)
{
if(This->sp)
IServiceProvider_Release(This->sp);
heap_free(This);
}
return ref;
}
@ -299,6 +304,9 @@ static HRESULT WINAPI AXSite_QueryService(IServiceProvider *iface,
TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
if(!This->sp)
return E_NOINTERFACE;
return IServiceProvider_QueryService(This->sp, guidService, riid, ppv);
}
@ -311,14 +319,13 @@ static IServiceProviderVtbl AXSiteVtbl = {
IUnknown *create_ax_site(script_ctx_t *ctx)
{
IServiceProvider *sp;
IServiceProvider *sp = NULL;
AXSite *ret;
HRESULT hres;
hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IServiceProvider, (void**)&sp);
if(FAILED(hres)) {
ERR("Could not get IServiceProvider iface: %08x\n", hres);
return NULL;
TRACE("Could not get IServiceProvider iface: %08x\n", hres);
}
ret = heap_alloc(sizeof(AXSite));

View file

@ -80,6 +80,7 @@ static DWORD QueryCustomPolicy_psize;
static DWORD QueryCustomPolicy_policy;
static HRESULT QI_IDispatch_hres;
static HRESULT SetSite_hres;
static BOOL AllowIServiceProvider;
#define TESTOBJ_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80646}"
@ -575,7 +576,7 @@ static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface,
*ppv = iface;
}else if(IsEqualGUID(&IID_IActiveScriptSite, riid)) {
*ppv = iface;
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
}else if(IsEqualGUID(&IID_IServiceProvider, riid) && AllowIServiceProvider) {
*ppv = &ServiceProvider;
}else {
*ppv = NULL;
@ -718,6 +719,7 @@ static IActiveScriptParse *create_script(BOOL skip_tests, BOOL use_sec_mgr)
QueryCustomPolicy_policy = URLPOLICY_ALLOW;
QI_IDispatch_hres = S_OK;
SetSite_hres = S_OK;
AllowIServiceProvider = TRUE;
hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IActiveScript, (void**)&script);
@ -1032,6 +1034,31 @@ static void test_ActiveXObject(void)
CHECK_CALLED(SetSite);
IUnknown_Release(parser);
/* No IServiceProvider Interface */
parser = create_script(FALSE, FALSE);
object_with_site = &ObjectWithSite;
AllowIServiceProvider = FALSE;
SET_EXPECT(CreateInstance);
SET_EXPECT(QI_IObjectWithSite);
SET_EXPECT(reportSuccess);
SET_EXPECT(SetSite);
parse_script_a(parser, "(new ActiveXObject('Wine.Test')).reportSuccess();");
CHECK_CALLED(CreateInstance);
CHECK_CALLED(QI_IObjectWithSite);
CHECK_CALLED(reportSuccess);
CHECK_CALLED(SetSite);
IUnknown_Release(parser);
parser = create_script(FALSE, TRUE);
object_with_site = &ObjectWithSite;
AllowIServiceProvider = FALSE;
parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.Test'); }, 'Error', -2146827859);");
IUnknown_Release(parser);
}
static BOOL init_key(const char *key_name, const char *def_value, BOOL init)