jscript: Added SCRIPTSTATE_STARTED implementation.

This commit is contained in:
Jacek Caban 2008-09-05 02:38:17 +02:00 committed by Alexandre Julliard
parent 69f8b4b9b2
commit 51a2ccb4c4
2 changed files with 37 additions and 2 deletions

View File

@ -116,6 +116,16 @@ static void clear_script_queue(JScript *This)
This->queue_head = This->queue_tail = NULL; This->queue_head = This->queue_tail = NULL;
} }
static void exec_queued_code(JScript *This)
{
parser_ctx_t *iter;
for(iter = This->queue_head; iter; iter = iter->next)
exec_global_code(This, iter);
clear_script_queue(This);
}
#define ACTSCRIPT_THIS(iface) DEFINE_THIS(JScript, IActiveScript, iface) #define ACTSCRIPT_THIS(iface) DEFINE_THIS(JScript, IActiveScript, iface)
static HRESULT WINAPI JScript_QueryInterface(IActiveScript *iface, REFIID riid, void **ppv) static HRESULT WINAPI JScript_QueryInterface(IActiveScript *iface, REFIID riid, void **ppv)
@ -235,8 +245,26 @@ static HRESULT WINAPI JScript_GetScriptSite(IActiveScript *iface, REFIID riid,
static HRESULT WINAPI JScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE ss) static HRESULT WINAPI JScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE ss)
{ {
JScript *This = ACTSCRIPT_THIS(iface); JScript *This = ACTSCRIPT_THIS(iface);
FIXME("(%p)->(%d)\n", This, ss);
TRACE("(%p)->(%d)\n", This, ss);
if(!This->ctx || GetCurrentThreadId() != This->thread_id)
return E_UNEXPECTED;
switch(ss) {
case SCRIPTSTATE_STARTED:
if(This->ctx->state == SCRIPTSTATE_CLOSED)
return E_UNEXPECTED;
exec_queued_code(This);
break;
default:
FIXME("unimplemented state %d\n", ss);
return E_NOTIMPL; return E_NOTIMPL;
}
change_state(This, ss);
return S_OK;
} }
static HRESULT WINAPI JScript_GetScriptState(IActiveScript *iface, SCRIPTSTATE *pssState) static HRESULT WINAPI JScript_GetScriptState(IActiveScript *iface, SCRIPTSTATE *pssState)

View File

@ -317,6 +317,13 @@ static void test_jscript(void)
test_script_dispatch(script, TRUE); test_script_dispatch(script, TRUE);
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); SET_EXPECT(OnStateChange_CLOSED);
hres = IActiveScript_Close(script); hres = IActiveScript_Close(script);
ok(hres == S_OK, "Close failed: %08x\n", hres); ok(hres == S_OK, "Close failed: %08x\n", hres);