Commit 9373ec4c authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Implement IActiveScriptSite service.

parent 384d5bfd
......@@ -1035,6 +1035,14 @@ static HRESULT WINAPI JSCaller_QueryService(IServiceProvider *iface, REFGUID gui
{
JSCaller *This = impl_from_IServiceProvider(iface);
if(IsEqualGUID(guidService, &IID_IActiveScriptSite)) {
TRACE("(%p)->(IID_IActiveScriptSite)\n", This);
if(This->ctx && This->ctx->site)
return IActiveScriptSite_QueryInterface(This->ctx->site, riid, ppv);
*ppv = NULL;
return E_NOINTERFACE;
}
if(IsEqualGUID(guidService, &SID_GetCaller)) {
TRACE("(%p)->(SID_GetCaller)\n", This);
*ppv = NULL;
......
......@@ -75,6 +75,7 @@ static const CLSID CLSID_JScript =
expect_ ## func = called_ ## func = FALSE
DEFINE_EXPECT(sp_caller_QI_NULL);
DEFINE_EXPECT(site_QI_NULL);
DEFINE_EXPECT(testArgConv);
DEFINE_EXPECT(testGetCaller);
DEFINE_EXPECT(testGetCallerJS);
......@@ -254,6 +255,7 @@ static void test_change_types(IVariantChangeType *change_type, IDispatch *obj_di
static void test_caller(IServiceProvider *caller, IDispatch *arg_obj)
{
IVariantChangeType *change_type;
IUnknown *unk;
HRESULT hres;
hres = IServiceProvider_QueryService(caller, &SID_VariantConversion, &IID_IVariantChangeType, (void**)&change_type);
......@@ -263,6 +265,12 @@ static void test_caller(IServiceProvider *caller, IDispatch *arg_obj)
test_change_types(change_type, arg_obj);
IVariantChangeType_Release(change_type);
SET_EXPECT(site_QI_NULL);
hres = IServiceProvider_QueryService(caller, &IID_IActiveScriptSite, &IID_NULL, (void**)&unk);
ok(hres == E_NOINTERFACE, "Querying for IActiveScriptSite->NULL returned: %08lx\n", hres);
ok(!unk, "unk != NULL\n");
CHECK_CALLED(site_QI_NULL);
}
static IServiceProvider sp_caller_obj;
......@@ -567,6 +575,8 @@ static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface,
}else if(IsEqualGUID(&IID_IActiveScriptSite, riid)) {
*ppv = iface;
}else {
if(IsEqualGUID(&IID_NULL, riid))
CHECK_EXPECT(site_QI_NULL);
*ppv = NULL;
return E_NOINTERFACE;
}
......
......@@ -313,6 +313,36 @@ fail:
return SysAllocString(L"File");
}
static void test_sp_caller(IServiceProvider *sp)
{
IOleCommandTarget *cmdtarget;
IServiceProvider *caller;
IHTMLWindow2 *window;
HRESULT hres;
VARIANT var;
hres = IServiceProvider_QueryService(sp, &SID_GetCaller, &IID_IServiceProvider, (void**)&caller);
ok(hres == S_OK, "QueryService(SID_GetCaller) returned: %08lx\n", hres);
ok(!caller, "caller != NULL\n");
hres = IServiceProvider_QueryService(sp, &IID_IActiveScriptSite, &IID_IOleCommandTarget, (void**)&cmdtarget);
ok(hres == S_OK, "QueryService(IActiveScriptSite->IOleCommandTarget) failed: %08lx\n", hres);
ok(cmdtarget != NULL, "IOleCommandTarget is NULL\n");
V_VT(&var) = VT_EMPTY;
hres = IOleCommandTarget_Exec(cmdtarget, &CGID_ScriptSite, CMDID_SCRIPTSITE_SECURITY_WINDOW, 0, NULL, &var);
ok(hres == S_OK, "Exec failed: %08lx\n", hres);
ok(V_VT(&var) == VT_DISPATCH, "V_VT(CMDID_SCRIPTSITE_SECURITY_WINDOW) = %d\n", V_VT(&var));
ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(CMDID_SCRIPTSITE_SECURITY_WINDOW) = NULL\n");
IOleCommandTarget_Release(cmdtarget);
hres = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IHTMLWindow2, (void**)&window);
ok(hres == S_OK, "QueryInterface(IHTMLWindow2) failed: %08lx\n", hres);
ok(window != NULL, "window is NULL\n");
IHTMLWindow2_Release(window);
VariantClear(&var);
}
static void test_script_vars(unsigned argc, VARIANTARG *argv)
{
static const WCHAR *const jsobj_names[] = { L"abc", L"foO", L"bar", L"TostRing", L"hasownpropERty" };
......@@ -1170,6 +1200,7 @@ static HRESULT WINAPI externalDisp_InvokeEx(IDispatchEx *iface, DISPID id, LCID
ok(!pvarRes, "pvarRes != NULL\n");
ok(pei != NULL, "pei == NULL\n");
test_sp_caller(pspCaller);
return S_OK;
case DISPID_EXTERNAL_TODO_WINE_OK:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment