From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/dispex.c | 13 ++++++++++--- dlls/mshtml/htmlimg.c | 11 ++++++----- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/tests/documentmode.js | 1 + dlls/mshtml/tests/es5.js | 5 +++++ 5 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index d4c560bab75..c464d6f5607 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -1800,9 +1800,16 @@ static void init_host_object(DispatchEx *dispex, HTMLInnerWindow *script_global, if(!script_global->jscript) initialize_script_global(script_global); if(script_global->jscript && !dispex->jsdisp) { - hres = IWineJScript_InitHostObject(script_global->jscript, &dispex->IWineJSDispatchHost_iface, - prototype ? prototype->jsdisp : NULL, - dispex->info->desc->js_flags, &dispex->jsdisp); + if(dispex->info->desc->constructor_id) { + DispatchEx *prototype; + if(FAILED(hres = get_prototype(script_global, dispex->info->desc->constructor_id, &prototype))) + return; + hres = IWineJScript_InitHostConstructor(script_global->jscript, &dispex->IWineJSDispatchHost_iface, + prototype->jsdisp, &dispex->jsdisp); + }else + hres = IWineJScript_InitHostObject(script_global->jscript, &dispex->IWineJSDispatchHost_iface, + prototype ? prototype->jsdisp : NULL, + dispex->info->desc->js_flags, &dispex->jsdisp); if(FAILED(hres)) ERR("Failed to initialize jsdisp: %08lx\n", hres); } diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index 9295c5cc2e2..08119464806 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -885,10 +885,11 @@ static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = { };
static dispex_static_data_t HTMLImageElementFactory_dispex = { - "Function", - &HTMLImageElementFactory_dispex_vtbl, - IHTMLImageElementFactory_tid, - HTMLImageElementFactory_iface_tids + .name = "Function", + .constructor_id = PROT_HTMLImageElement, + .vtbl = &HTMLImageElementFactory_dispex_vtbl, + .disp_tid = IHTMLImageElementFactory_tid, + .iface_tids = HTMLImageElementFactory_iface_tids, };
HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow *window, HTMLImageElementFactory **ret_val) @@ -903,7 +904,7 @@ HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow *window, HTMLImageElement ret->window = window; IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
- init_dispatch(&ret->dispex, &HTMLImageElementFactory_dispex, NULL, + init_dispatch(&ret->dispex, &HTMLImageElementFactory_dispex, window, dispex_compat_mode(&window->event_target.dispex));
*ret_val = ret; diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 21b2866de2c..9d5833b7e09 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -438,6 +438,7 @@ typedef struct { dispex_data_t *delayed_init_info; prototype_id_t id; prototype_id_t prototype_id; + prototype_id_t constructor_id; UINT32 js_flags; char prototype_name[64]; } dispex_static_data_t; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 40dc74ccfcf..14c797a10da 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3138,4 +3138,5 @@ sync_test("prototypes", function() { check(Window.prototype, Object.prototype, "window prototype"); check(document.createElement("img"), HTMLImageElement.prototype, "img elem"); check(HTMLImageElement.prototype, HTMLElement.prototype, "img elem prototype"); + check(Image, Function.prototype, "Image constructor"); }); diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index b5fdbdf708a..f049a526bf4 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -2761,6 +2761,11 @@ sync_test("prototypes", function() { ok(!Element.prototype.hasOwnProperty("removeChild"), "Element prototype has own removeChild property"); ok(Node.prototype.hasOwnProperty("removeChild"), "Node prototype does not have own removeChild property");
+ ok(Image != HTMLImageElement, "Image == HTMLImageElement"); + ok(typeof(HTMLImageElement) === "object", "typeof(HTMLImageElement) = " + typeof(HTMLImageElement)); + ok(typeof(Image) === "function", "typeof(Image) = " + typeof(Image)); + ok(Image.prototype === HTMLImageElement.prototype, "Image.prototype != HTMLImageElement.prototype"); + ok(document.implementation instanceof DOMImplementation, "document.implementation is not an instance of DOMImplementation"); ok(navigator instanceof Navigator, "navigator is not an instance of Navigator"); ok(!(navigator instanceof DOMImplementation), "navigator is an instance of DOMImplementation");