Commit b5290bde authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added a test using script dispatch after closing engine.

parent 2c0edb94
...@@ -203,37 +203,70 @@ static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = { ...@@ -203,37 +203,70 @@ static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = {
static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl }; static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl };
static void test_script_dispatch(IActiveScript *script, BOOL initialized) static void test_script_dispatch(IDispatchEx *dispex)
{ {
IDispatchEx *dispex; DISPPARAMS dp = {NULL,NULL,0,0};
IDispatch *disp; EXCEPINFO ei;
BSTR str; BSTR str;
DISPID id; DISPID id;
VARIANT v;
HRESULT hres; HRESULT hres;
disp = (void*)0xdeadbeef; str = a2bstr("ActiveXObject");
hres = IActiveScript_GetScriptDispatch(script, NULL, &disp); hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
if(!initialized) { SysFreeString(str);
ok(hres == E_UNEXPECTED, "hres = %08x, expected E_UNEXPECTED\n", hres); ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
ok(!disp, "disp != NULL\n");
return;
}
ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres); str = a2bstr("Math");
if(FAILED(hres)) hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
return; SysFreeString(str);
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
ok(disp != NULL, "disp == NULL\n"); memset(&ei, 0, sizeof(ei));
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
IDispatch_Release(disp); ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
ok(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres); ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
ok(V_DISPATCH(&v) != NULL, "V_DISPATCH(v) = NULL\n");
VariantClear(&v);
str = a2bstr("ActiveXObject"); str = a2bstr("String");
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id); hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
SysFreeString(str); SysFreeString(str);
ok(hres == S_OK, "GetDispID failed: %08x\n", hres); ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
IDispatchEx_Release(dispex); memset(&ei, 0, sizeof(ei));
hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
ok(V_DISPATCH(&v) != NULL, "V_DISPATCH(v) = NULL\n");
VariantClear(&v);
}
static IDispatchEx *get_script_dispatch(IActiveScript *script)
{
IDispatchEx *dispex;
IDispatch *disp;
HRESULT hres;
disp = (void*)0xdeadbeef;
hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
IDispatch_Release(disp);
ok(hres == S_OK, "Could not get IDispatch iface: %08x\n", hres);
return dispex;
}
static void test_no_script_dispatch(IActiveScript *script)
{
IDispatch *disp;
HRESULT hres;
disp = (void*)0xdeadbeef;
hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
ok(hres == E_UNEXPECTED, "hres = %08x, expected E_UNEXPECTED\n", hres);
ok(!disp, "disp != NULL\n");
} }
static void test_safety(IUnknown *unk) static void test_safety(IUnknown *unk)
...@@ -342,6 +375,7 @@ static void test_jscript(void) ...@@ -342,6 +375,7 @@ static void test_jscript(void)
{ {
IActiveScriptParse *parse; IActiveScriptParse *parse;
IActiveScript *script; IActiveScript *script;
IDispatchEx *dispex;
IUnknown *unk; IUnknown *unk;
ULONG ref; ULONG ref;
HRESULT hres; HRESULT hres;
...@@ -377,7 +411,7 @@ static void test_jscript(void) ...@@ -377,7 +411,7 @@ static void test_jscript(void)
ok(hres == E_POINTER, "SetScriptSite failed: %08x, expected E_POINTER\n", hres); ok(hres == E_POINTER, "SetScriptSite failed: %08x, expected E_POINTER\n", hres);
test_state(script, SCRIPTSTATE_UNINITIALIZED); test_state(script, SCRIPTSTATE_UNINITIALIZED);
test_script_dispatch(script, FALSE); test_no_script_dispatch(script);
SET_EXPECT(GetLCID); SET_EXPECT(GetLCID);
SET_EXPECT(OnStateChange_INITIALIZED); SET_EXPECT(OnStateChange_INITIALIZED);
...@@ -391,7 +425,8 @@ static void test_jscript(void) ...@@ -391,7 +425,8 @@ static void test_jscript(void)
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite); hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres); ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres);
test_script_dispatch(script, TRUE); dispex = get_script_dispatch(script);
test_script_dispatch(dispex);
SET_EXPECT(OnStateChange_STARTED); SET_EXPECT(OnStateChange_STARTED);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED); hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED);
...@@ -406,7 +441,9 @@ static void test_jscript(void) ...@@ -406,7 +441,9 @@ static void test_jscript(void)
CHECK_CALLED(OnStateChange_CLOSED); CHECK_CALLED(OnStateChange_CLOSED);
test_state(script, SCRIPTSTATE_CLOSED); test_state(script, SCRIPTSTATE_CLOSED);
test_script_dispatch(script, FALSE); test_no_script_dispatch(script);
test_script_dispatch(dispex);
IDispatchEx_Release(dispex);
IUnknown_Release(parse); IUnknown_Release(parse);
IActiveScript_Release(script); IActiveScript_Release(script);
...@@ -474,7 +511,7 @@ static void test_jscript2(void) ...@@ -474,7 +511,7 @@ static void test_jscript2(void)
CHECK_CALLED(OnStateChange_CLOSED); CHECK_CALLED(OnStateChange_CLOSED);
test_state(script, SCRIPTSTATE_CLOSED); test_state(script, SCRIPTSTATE_CLOSED);
test_script_dispatch(script, FALSE); test_no_script_dispatch(script);
IUnknown_Release(parse); IUnknown_Release(parse);
IActiveScript_Release(script); IActiveScript_Release(script);
......
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