jscript: Don't allow starting script using state from uninitialized.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gabriel Ivăncescu 2022-06-02 20:00:43 +03:00 committed by Alexandre Julliard
parent 3eaac7211f
commit 079b14b2e9
2 changed files with 7 additions and 1 deletions

View file

@ -824,7 +824,7 @@ static HRESULT WINAPI JScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE s
switch(ss) {
case SCRIPTSTATE_STARTED:
case SCRIPTSTATE_CONNECTED: /* FIXME */
if(This->ctx->state == SCRIPTSTATE_CLOSED)
if(This->ctx->state == SCRIPTSTATE_UNINITIALIZED || This->ctx->state == SCRIPTSTATE_CLOSED)
return E_UNEXPECTED;
exec_queued_code(This);

View file

@ -863,6 +863,12 @@ static void test_jscript_uninitializing(void)
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08lx\n", hres);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED);
ok(hres == E_UNEXPECTED, "SetScriptState(SCRIPTSTATE_STARTED) returned: %08lx\n", hres);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
ok(hres == E_UNEXPECTED, "SetScriptState(SCRIPTSTATE_CONNECTED) returned: %08lx\n", hres);
SET_EXPECT(GetLCID);
SET_EXPECT(OnStateChange_INITIALIZED);
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);