From: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> Otherwise, the prototype and all the related info may never be initialized, as the script can simply access properties of the object without interacting with the object's methods and so ensure_real_info never ends up called. Note that we can't do this from within create_document_node, as that will break if it's a document created from update_window_doc (the window's doc is not set at that point, since it's being created, and ensure_real_info needs it). Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- dlls/mshtml/omnavigator.c | 8 +++++++- dlls/mshtml/tests/es5.js | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index 6b255d4cd54..8dd785e72ba 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -113,6 +113,7 @@ static HRESULT WINAPI HTMLDOMImplementation2_createHTMLDocument(IHTMLDOMImplemen { HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface); HTMLDocumentNode *new_document_node; + compat_mode_t compat_mode; nsIDOMDocument *doc; nsAString title_str; nsresult nsres; @@ -131,12 +132,17 @@ static HRESULT WINAPI HTMLDOMImplementation2_createHTMLDocument(IHTMLDOMImplemen return E_FAIL; } + compat_mode = dispex_compat_mode(&This->dispex); hres = create_document_node(doc, This->doc->browser, NULL, This->doc->script_global, - dispex_compat_mode(&This->dispex), &new_document_node); + compat_mode, &new_document_node); nsIDOMDocument_Release(doc); if(FAILED(hres)) return hres; + /* make sure dispex info is initialized for the prototype */ + if(compat_mode >= COMPAT_MODE_IE9) + dispex_compat_mode(&new_document_node->node.event_target.dispex); + *new_document = &new_document_node->IHTMLDocument7_iface; return S_OK; } diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index fe4c8ac7a7e..2f62f051d33 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -2845,7 +2845,6 @@ async_test("script_global", function() { // Created documents share script global, so their objects are instances of Object from // the current script context. var doc = document.implementation.createHTMLDocument("test"); - todo_wine. ok(doc instanceof Object, "created doc is not an instance of Object"); ok(doc.implementation instanceof Object, "created doc.implementation is not an instance of Object"); ok(doc.implementation instanceof DOMImplementation, "created doc.implementation is not an instance of DOMImplementation"); @@ -2870,9 +2869,17 @@ async_test("script_global", function() { ok(!(doc.implementation instanceof DOMImplementation), "created iframe doc.implementation is an instance of DOMImplementation"); ok(doc.implementation instanceof iframe.contentWindow.DOMImplementation, "created iframe doc.implementation is not an instance of iframe's DOMImplementation"); ok(Object.getPrototypeOf(doc) !== Object.getPrototypeOf(document), "created iframe doc's prototype same as doc prototype"); - todo_wine. ok(Object.getPrototypeOf(doc) === iframe.contentWindow.HTMLDocument.prototype, "created iframe doc's prototype not iframe's HTMLDocument.prototype"); + Object.defineProperty(doc, "winetest", { writable: true, enumerable: true, configurable: true, value: 42 }); + test_own_data_prop_desc(doc, "winetest", true, true, true); + + ok(Object.isFrozen(doc) === false, "created iframe doc isFrozen is not false"); + ok(Object.isSealed(doc) === false, "created iframe doc isSealed is not false"); + Object.freeze(doc); + ok(Object.isFrozen(doc) === true, "created iframe doc isFrozen is not true after freezing it"); + ok(Object.isSealed(doc) === true, "created iframe doc isSealed is not true after freezing it"); + var r = Object.prototype.toString.call(iframe.contentWindow); ok(r === "[object Window]", "iframe's Window toString = " + r); r = Object.prototype.toString.call(iframe.contentWindow.DOMImplementation); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7425