diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 1ba1101e819..d4069972471 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -1140,8 +1140,10 @@ static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BS VARIANT *pvarRet) { HTMLWindow *This = HTMLWINDOW2_THIS(iface); - FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet); - return E_NOTIMPL; + + TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet); + + return exec_script(This, scode, language, pvarRet); } static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index d9dd56334d5..a9099435e3d 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -856,6 +856,7 @@ void release_script_hosts(HTMLWindow*); void connect_scripts(HTMLWindow*); void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*); IDispatch *script_parse_event(HTMLWindow*,LPCWSTR); +HRESULT exec_script(HTMLWindow*,const WCHAR*,const WCHAR*,VARIANT*); void set_script_mode(HTMLWindow*,SCRIPTMODE); BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*); IDispatch *get_script_disp(ScriptHost*); diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c index 0b78e17dda0..4d50e36c141 100644 --- a/dlls/mshtml/script.c +++ b/dlls/mshtml/script.c @@ -874,6 +874,42 @@ IDispatch *script_parse_event(HTMLWindow *window, LPCWSTR text) return disp; } +HRESULT exec_script(HTMLWindow *window, const WCHAR *code, const WCHAR *lang, VARIANT *ret) +{ + ScriptHost *script_host; + EXCEPINFO ei; + GUID guid; + HRESULT hres; + + static const WCHAR delimW[] = {'"',0}; + + if(!get_guid_from_language(lang, &guid)) { + WARN("Could not find script GUID\n"); + return CO_E_CLASSSTRING; + } + + script_host = get_script_host(window, &guid); + if(!script_host) { + FIXME("No script host\n"); + return E_FAIL; + } + + if(!script_host->parse) { + FIXME("script_host->parse == NULL\n"); + return E_FAIL; + } + + memset(&ei, 0, sizeof(ei)); + TRACE(">>>\n"); + hres = IActiveScriptParse64_ParseScriptText(script_host->parse, code, NULL, NULL, delimW, 0, 0, SCRIPTTEXT_ISVISIBLE, ret, &ei); + if(SUCCEEDED(hres)) + TRACE("<<<\n"); + else + WARN("<<< %08x\n", hres); + + return hres; +} + IDispatch *get_script_disp(ScriptHost *script_host) { IDispatch *disp;