From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/function.c | 13 ++++++++++++- dlls/mshtml/dispex.c | 25 +++++++++++++++++++------ dlls/mshtml/htmlimg.c | 2 +- dlls/mshtml/htmlselect.c | 2 +- dlls/mshtml/mutation.c | 2 +- dlls/mshtml/tests/documentmode.js | 1 - dlls/mshtml/xmlhttprequest.c | 2 +- 7 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 24847e17686..567e2596969 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -1166,8 +1166,19 @@ static HRESULT HostConstructor_call(script_ctx_t *ctx, FunctionInstance *func, j static HRESULT HostConstructor_toString(FunctionInstance *func, jsstr_t **ret) { HostConstructor *function = (HostConstructor*)func; + HRESULT hres; + BSTR str; + + if(function->method_name) + return native_function_string(function->method_name, ret); + + hres = IWineJSDispatchHost_ToString(function->host_iface, &str); + if(FAILED(hres)) + return hres;
- return native_function_string(function->method_name, ret); + *ret = jsstr_alloc(str); + SysFreeString(str); + return *ret ? S_OK : E_OUTOFMEMORY; }
static function_code_t *HostConstructor_get_code(FunctionInstance *function) diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 58c7fd448b8..1e31cb66db1 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -1943,20 +1943,30 @@ compat_mode_t dispex_compat_mode(DispatchEx *dispex)
HRESULT dispex_to_string(DispatchEx *dispex, BSTR *ret) { + static const WCHAR func_prefix[10] = L"\nfunction "; + static const WCHAR func_suffix[] = L"() {\n [native code]\n}\n"; static const WCHAR prefix[8] = L"[object "; static const WCHAR suffix[] = L"]"; - WCHAR buf[ARRAY_SIZE(prefix) + ARRAY_SIZE(dispex->info->desc->prototype_name) + ARRAY_SIZE(suffix)], *p = buf; + WCHAR buf[ARRAY_SIZE(func_prefix) + ARRAY_SIZE(dispex->info->desc->prototype_name) + ARRAY_SIZE(func_suffix)], *p = buf; compat_mode_t compat_mode = dispex_compat_mode(dispex); const char *name;
if(!ret) return E_INVALIDARG;
- memcpy(p, prefix, sizeof(prefix)); - p += ARRAY_SIZE(prefix); if(compat_mode < COMPAT_MODE_IE9) - p--; + wcscpy(buf, L"[object]"); else { + BOOL is_func = dispex->info->desc->constructor_id; + + if(is_func) { + memcpy(p, func_prefix, sizeof(func_prefix)); + p += ARRAY_SIZE(func_prefix); + }else { + memcpy(p, prefix, sizeof(prefix)); + p += ARRAY_SIZE(prefix); + } + if(!ensure_real_info(dispex)) return E_OUTOFMEMORY; name = dispex->info->name; @@ -1964,9 +1974,12 @@ HRESULT dispex_to_string(DispatchEx *dispex, BSTR *ret) name = dispex->info->vtbl->get_name(dispex); while(*name) *p++ = *name++; - assert(p + ARRAY_SIZE(suffix) - buf <= ARRAY_SIZE(buf)); + + if(is_func) + memcpy(p, func_suffix, sizeof(func_suffix)); + else + memcpy(p, suffix, sizeof(suffix)); } - memcpy(p, suffix, sizeof(suffix));
*ret = SysAllocString(buf); return *ret ? S_OK : E_OUTOFMEMORY; diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index fda2037f392..40c2c2dd09b 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -857,7 +857,7 @@ static HRESULT HTMLImageElementFactory_init(struct constructor *constr) }
dispex_static_data_t Image_dispex = { - .name = "Function", + .name = "Image", .constructor_id = OBJID_HTMLImageElement, .init_constructor = HTMLImageElementFactory_init, .vtbl = &HTMLImageElementFactory_dispex_vtbl, diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index 232f9104bc7..a126f977697 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -503,7 +503,7 @@ static HRESULT HTMLOptionElementFactory_init(struct constructor *constr) }
dispex_static_data_t Option_dispex = { - .name = "Function", + .name = "Option", .constructor_id = OBJID_HTMLOptionElement, .init_constructor = HTMLOptionElementFactory_init, .vtbl = &HTMLOptionElementFactory_dispex_vtbl, diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c index 0ba3ce4a62f..b5ec41136ea 100644 --- a/dlls/mshtml/mutation.c +++ b/dlls/mshtml/mutation.c @@ -1301,7 +1301,7 @@ static const dispex_static_data_vtbl_t mutation_observer_ctor_dispex_vtbl = { };
static dispex_static_data_t mutation_observer_ctor_dispex = { - .name = "Function", + .name = "MutationObserver", .constructor_id = OBJID_MutationObserver, .vtbl = &mutation_observer_ctor_dispex_vtbl, }; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 5902ec04a30..f9967e8a6bd 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -4009,7 +4009,6 @@ sync_test("constructors", function() { r = ctors[i]; ok(window.hasOwnProperty(r), r + " not prop of window"); ok(!(r in Window.prototype), r + " is a prop of window's prototype"); - todo_wine. ok(window[r].toString() === "\nfunction " + r + "() {\n [native code]\n}\n", r + ".toString() = " + window[r].toString()); } ok(window.Image.prototype === window.HTMLImageElement.prototype, "Image.prototype != HTMLImageElement.prototype"); diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index da483970214..3097792c620 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -1616,7 +1616,7 @@ static const tid_t HTMLXMLHttpRequestFactory_iface_tids[] = { 0 }; static dispex_static_data_t HTMLXMLHttpRequestFactory_dispex = { - .name = "Function", + .name = "XMLHttpRequest", .constructor_id = OBJID_XMLHttpRequest, .vtbl = &HTMLXMLHttpRequestFactory_dispex_vtbl, .disp_tid = IHTMLXMLHttpRequestFactory_tid,