static void test_jscript(void) { IActiveScriptParse *parse; IActiveScript *script; IDispatchEx *dispex; ULONG ref; HRESULT hres; script = create_jscript(); hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse); ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres); test_state(script, SCRIPTSTATE_UNINITIALIZED); test_safety((IUnknown*)script); test_invoke_versioning(script); hres = IActiveScriptParse_InitNew(parse); ok(hres == S_OK, "InitNew failed: %08x\n", hres); hres = IActiveScriptParse_InitNew(parse); ok(hres == E_UNEXPECTED, "InitNew failed: %08x, expected E_UNEXPECTED\n", hres); hres = IActiveScript_SetScriptSite(script, NULL); ok(hres == E_POINTER, "SetScriptSite failed: %08x, expected E_POINTER\n", hres); test_state(script, SCRIPTSTATE_UNINITIALIZED); test_no_script_dispatch(script); SET_EXPECT(GetLCID); SET_EXPECT(OnStateChange_INITIALIZED); hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite); ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres); CHECK_CALLED(GetLCID); CHECK_CALLED(OnStateChange_INITIALIZED); test_state(script, SCRIPTSTATE_INITIALIZED); hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite); ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres); dispex = get_script_dispatch(script); test_script_dispatch(dispex); SET_EXPECT(OnStateChange_STARTED); hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED); ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres); CHECK_CALLED(OnStateChange_STARTED); test_state(script, SCRIPTSTATE_STARTED); SET_EXPECT(OnStateChange_CLOSED); hres = IActiveScript_Close(script); ok(hres == S_OK, "Close failed: %08x\n", hres); CHECK_CALLED(OnStateChange_CLOSED); test_state(script, SCRIPTSTATE_CLOSED); test_no_script_dispatch(script); test_script_dispatch(dispex); IDispatchEx_Release(dispex); IActiveScriptParse_Release(parse); ref = IActiveScript_Release(script); ok(!ref, "ref = %d\n", ref); }
static void test_jscript(void) { IActiveScriptParse *parse; IActiveScript *script; IDispatchEx *dispex; IUnknown *unk; ULONG ref; HRESULT hres; hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void**)&unk); ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres); if(FAILED(hres)) return; hres = IUnknown_QueryInterface(unk, &IID_IActiveScript, (void**)&script); ok(hres == S_OK, "Could not get IActiveScript: %08x\n", hres); hres = IUnknown_QueryInterface(unk, &IID_IActiveScriptParse, (void**)&parse); ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres); if (FAILED(hres)) { IActiveScript_Release(script); return; } test_state(script, SCRIPTSTATE_UNINITIALIZED); test_safety(unk); test_invoke_versioning(script); hres = IActiveScriptParse64_InitNew(parse); ok(hres == S_OK, "InitNew failed: %08x\n", hres); hres = IActiveScriptParse64_InitNew(parse); ok(hres == E_UNEXPECTED, "InitNew failed: %08x, expected E_UNEXPECTED\n", hres); hres = IActiveScript_SetScriptSite(script, NULL); ok(hres == E_POINTER, "SetScriptSite failed: %08x, expected E_POINTER\n", hres); test_state(script, SCRIPTSTATE_UNINITIALIZED); test_no_script_dispatch(script); SET_EXPECT(GetLCID); SET_EXPECT(OnStateChange_INITIALIZED); hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite); ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres); CHECK_CALLED(GetLCID); CHECK_CALLED(OnStateChange_INITIALIZED); test_state(script, SCRIPTSTATE_INITIALIZED); hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite); ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres); dispex = get_script_dispatch(script); test_script_dispatch(dispex); SET_EXPECT(OnStateChange_STARTED); hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED); ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres); CHECK_CALLED(OnStateChange_STARTED); test_state(script, SCRIPTSTATE_STARTED); SET_EXPECT(OnStateChange_CLOSED); hres = IActiveScript_Close(script); ok(hres == S_OK, "Close failed: %08x\n", hres); CHECK_CALLED(OnStateChange_CLOSED); test_state(script, SCRIPTSTATE_CLOSED); test_no_script_dispatch(script); test_script_dispatch(dispex); IDispatchEx_Release(dispex); IUnknown_Release(parse); IActiveScript_Release(script); ref = IUnknown_Release(unk); ok(!ref, "ref = %d\n", ref); }