-- v2: mshtml/tests: Test iframe window navigation resetting props. mshtml: Get rid of useless "iter" member in the attribute collection enum. mshtml: Expose "arguments" and "caller" from host constructors in IE9+ modes. mshtml: Expose "caller" from host functions in IE9+ modes. mshtml: Expose "arguments" from host functions in IE9+ modes. jscript: Properly fill the builtin props. mshtml: Don't redefine deleted props in dispex_define_property. mshtml: Ignore setting non-writable external props.
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/dispex.c | 2 ++ dlls/mshtml/tests/documentmode.js | 32 ++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 03b400a383f..b1af74abc79 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -659,6 +659,8 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val) TRACE("no prop_put\n"); return S_OK; } + if(!(prop->flags & PROPF_WRITABLE)) + return S_OK; hres = This->builtin_info->prop_put(This, prop->u.id, val); if(hres != S_FALSE) return hres; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 634f4ad3420..9aa199bcadc 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -4012,7 +4012,7 @@ sync_test("prototype props", function() { });
sync_test("constructors", function() { - var v = document.documentMode, i, r; + var v = document.documentMode, i, r, old; if(v < 9) return;
@@ -4038,4 +4038,34 @@ sync_test("constructors", function() { }catch(e) { ok(e.number === 0x0ffff - 0x80000000, "new XMLHttpRequest.create() threw " + e.number); } + + r = Object.getOwnPropertyDescriptor(HTMLMetaElement, "prototype"); + ok(r.value === HTMLMetaElement.prototype, "HTMLMetaElement.prototype value = " + r.value); + ok(!("get" in r), "HTMLMetaElement.prototype has getter"); + ok(!("set" in r), "HTMLMetaElement.prototype has setter"); + ok(r.writable === false, "HTMLMetaElement.prototype writable = " + r.writable); + ok(r.enumerable === false, "HTMLMetaElement.prototype enumerable = " + r.enumerable); + ok(r.configurable === false, "HTMLMetaElement.prototype configurable = " + r.configurable); + + old = HTMLMetaElement.prototype; + HTMLMetaElement.prototype = Object.prototype; + ok(HTMLMetaElement.prototype === old, "HTMLMetaElement.prototype = " + HTMLMetaElement.prototype); + + r = (delete HTMLMetaElement.prototype); + ok(r === false, "delete HTMLMetaElement.prototype returned " + r); + ok(HTMLMetaElement.hasOwnProperty("prototype"), "prototype not a prop anymore of HTMLMetaElement"); + + old = window.HTMLMetaElement; + r = (delete window.HTMLMetaElement); + ok(r === true, "delete HTMLMetaElement returned " + r); + todo_wine. + ok(!window.hasOwnProperty("HTMLMetaElement"), "HTMLMetaElement still a property of window"); + window.HTMLMetaElement = old; + + old = HTMLMetaElement.prototype.constructor; + r = (delete HTMLMetaElement.prototype.constructor); + ok(r === true, "delete HTMLMetaElement.prototype.constructor returned " + r); + todo_wine. + ok(!HTMLMetaElement.prototype.hasOwnProperty("constructor"), "constructor still a property of HTMLMetaElement.prototype"); + HTMLMetaElement.prototype.constructor = old; });
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/dispex.c | 8 ++++++++ dlls/mshtml/htmlwindow.c | 4 +++- dlls/mshtml/tests/documentmode.js | 2 -- 3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 21927315443..43896729a9e 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -803,6 +803,14 @@ HRESULT dispex_define_property(DispatchEx *dispex, const WCHAR *name, DWORD flag dynamic_prop_t *prop; HRESULT hres;
+ if(flags & PROPF_CONFIGURABLE) { + prop = NULL; + hres = get_dynamic_prop(dispex, name, 0, &prop); + assert(FAILED(hres)); + if(prop) + return hres; + } + hres = alloc_dynamic_prop(dispex, name, NULL, &prop); if(FAILED(hres)) return hres; diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index c8c0c7c1ea6..8913c4e511c 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -3816,7 +3816,9 @@ static HRESULT HTMLWindow_find_dispid(DispatchEx *dispex, const WCHAR *name, DWO
V_VT(&v) = VT_DISPATCH; V_DISPATCH(&v) = (IDispatch *)&constr->IWineJSDispatchHost_iface; - return dispex_define_property(&This->event_target.dispex, name, PROPF_WRITABLE | PROPF_CONFIGURABLE, &v, dispid); + hres = dispex_define_property(&This->event_target.dispex, name, PROPF_WRITABLE | PROPF_CONFIGURABLE, &v, dispid); + if(hres != DISP_E_UNKNOWNNAME) + return hres; } } } diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 9aa199bcadc..073ca769cca 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -4058,14 +4058,12 @@ sync_test("constructors", function() { old = window.HTMLMetaElement; r = (delete window.HTMLMetaElement); ok(r === true, "delete HTMLMetaElement returned " + r); - todo_wine. ok(!window.hasOwnProperty("HTMLMetaElement"), "HTMLMetaElement still a property of window"); window.HTMLMetaElement = old;
old = HTMLMetaElement.prototype.constructor; r = (delete HTMLMetaElement.prototype.constructor); ok(r === true, "delete HTMLMetaElement.prototype.constructor returned " + r); - todo_wine. ok(!HTMLMetaElement.prototype.hasOwnProperty("constructor"), "constructor still a property of HTMLMetaElement.prototype"); HTMLMetaElement.prototype.constructor = old; });
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/dispex.c | 7 +++++++ dlls/mshtml/tests/es5.js | 1 - 2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index b1af74abc79..058945d1a5f 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -750,6 +750,13 @@ static HRESULT fill_props(jsdisp_t *obj) { dispex_prop_t *prop; HRESULT hres; + DWORD i; + + for(i = 0; i < obj->builtin_info->props_cnt; i++) { + hres = find_prop_name(obj, string_hash(obj->builtin_info->props[i].name), obj->builtin_info->props[i].name, FALSE, NULL, &prop); + if(FAILED(hres)) + return hres; + }
if(obj->builtin_info->next_prop) { struct property_info desc; diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index 2f62f051d33..1781df69ee3 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -1356,7 +1356,6 @@ sync_test("getOwnPropertyNames", function() { ok(names === "defined,test", "names = " + names);
names = Object.getOwnPropertyNames([]).sort().join(); - todo_wine. ok(names === "length", "names = " + names);
ok(Object.getOwnPropertyNames.length === 1, "Object.getOwnPropertyNames.length = " + Object.getOwnPropertyNames.length);
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/function.c | 6 ++++++ dlls/mshtml/tests/documentmode.js | 5 +++++ 2 files changed, 11 insertions(+)
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 567e2596969..2e811b857cd 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -976,10 +976,16 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_cod return S_OK; }
+static const builtin_prop_t HostFunction_props[] = { + {L"arguments", NULL, 0, Function_get_arguments}, +}; + static const builtin_info_t HostFunction_info = { .class = JSCLASS_FUNCTION, .call = Function_value, .destructor = Function_destructor, + .props_cnt = ARRAY_SIZE(HostFunction_props), + .props = HostFunction_props, .gc_traverse = Function_gc_traverse };
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 073ca769cca..e7c2db6508a 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -375,6 +375,7 @@ sync_test("builtin_obj", function() { ok(!(f.apply instanceof Function), "f.apply instance of Function"); ok(!(f.call instanceof Function), "f.call instance of Function"); ok(!("arguments" in f), "arguments in f"); + ok(!("caller" in f), "caller in f"); ok(!("length" in f), "length in f"); e = 0; try { @@ -393,6 +394,9 @@ sync_test("builtin_obj", function() { ok(e === "[object Window]", "window.toString with null context = " + e); e = window.toString.call(external.nullDisp); ok(e === "[object Window]", "window.toString with nullDisp context = " + e); + + test_own_props(f, "createElement", [ "arguments", "caller", "prototype" ], [ "caller", "prototype" ]); + ok(f.arguments === null, "createElement arguments = " + f.arguments); }
e = 0; @@ -4038,6 +4042,7 @@ sync_test("constructors", function() { }catch(e) { ok(e.number === 0x0ffff - 0x80000000, "new XMLHttpRequest.create() threw " + e.number); } + test_own_props(XMLHttpRequest.create, "XMLHttpRequest.create", [ "arguments", "caller", "prototype" ], [ "arguments", "caller", "prototype" ]);
r = Object.getOwnPropertyDescriptor(HTMLMetaElement, "prototype"); ok(r.value === HTMLMetaElement.prototype, "HTMLMetaElement.prototype value = " + r.value);
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/function.c | 1 + dlls/mshtml/tests/documentmode.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 2e811b857cd..8f4b836ff76 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -978,6 +978,7 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_cod
static const builtin_prop_t HostFunction_props[] = { {L"arguments", NULL, 0, Function_get_arguments}, + {L"caller", NULL, 0, Function_get_caller}, };
static const builtin_info_t HostFunction_info = { diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index e7c2db6508a..5f9892a0713 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -395,7 +395,7 @@ sync_test("builtin_obj", function() { e = window.toString.call(external.nullDisp); ok(e === "[object Window]", "window.toString with nullDisp context = " + e);
- test_own_props(f, "createElement", [ "arguments", "caller", "prototype" ], [ "caller", "prototype" ]); + test_own_props(f, "createElement", [ "arguments", "caller", "prototype" ], [ "prototype" ]); ok(f.arguments === null, "createElement arguments = " + f.arguments); }
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/function.c | 2 ++ dlls/mshtml/tests/documentmode.js | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 8f4b836ff76..54b8f5abe2f 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -1124,6 +1124,8 @@ static const builtin_info_t HostConstructor_info = { .release = HostConstructor_release, .call = Function_value, .destructor = Function_destructor, + .props_cnt = ARRAY_SIZE(HostFunction_props), + .props = HostFunction_props, .gc_traverse = Function_gc_traverse, .lookup_prop = HostConstructor_lookup_prop, }; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 5f9892a0713..e35b978db46 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -4028,6 +4028,11 @@ sync_test("constructors", function() { ok(window.hasOwnProperty(r), r + " not prop of window"); ok(!(r in Window.prototype), r + " is a prop of window's prototype"); ok(window[r].toString() === "\nfunction " + r + "() {\n [native code]\n}\n", r + ".toString() = " + window[r].toString()); + + ok(window[r].hasOwnProperty("arguments"), "arguments not a prop of " + r); + ok(window[r].hasOwnProperty("caller"), "caller not a prop of " + r); + ok(window[r].hasOwnProperty("prototype"), "prototype not a prop of " + r); + ok(!window[r].hasOwnProperty("length"), "length is a prop of " + r); } ok(window.Image.prototype === window.HTMLImageElement.prototype, "Image.prototype != HTMLImageElement.prototype"); ok(window.Option.prototype === window.HTMLOptionElement.prototype, "Option.prototype != HTMLOptionElement.prototype"); @@ -4042,7 +4047,7 @@ sync_test("constructors", function() { }catch(e) { ok(e.number === 0x0ffff - 0x80000000, "new XMLHttpRequest.create() threw " + e.number); } - test_own_props(XMLHttpRequest.create, "XMLHttpRequest.create", [ "arguments", "caller", "prototype" ], [ "arguments", "caller", "prototype" ]); + test_own_props(XMLHttpRequest.create, "XMLHttpRequest.create", [ "arguments", "caller", "prototype" ], [ "prototype" ]);
r = Object.getOwnPropertyDescriptor(HTMLMetaElement, "prototype"); ok(r.value === HTMLMetaElement.prototype, "HTMLMetaElement.prototype value = " + r.value);
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlelem.c | 5 ----- 1 file changed, 5 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 86efd8fab4f..89fa136ddd2 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -7761,7 +7761,6 @@ typedef struct {
LONG ref;
- ULONG iter; DISPID iter_dispid; HTMLAttributeCollection *col; } HTMLAttributeCollectionEnum; @@ -7846,7 +7845,6 @@ static HRESULT WINAPI HTMLAttributeCollectionEnum_Next(IEnumVARIANT *iface, ULON V_DISPATCH(&rgVar[i]) = (IDispatch*)&attr->IHTMLDOMAttribute_iface; }
- This->iter += i; This->iter_dispid = dispid; if(pCeltFetched) *pCeltFetched = i; @@ -7876,7 +7874,6 @@ static HRESULT WINAPI HTMLAttributeCollectionEnum_Skip(IEnumVARIANT *iface, ULON hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, &dispid); if(FAILED(hres)) return hres; - This->iter += remaining; This->iter_dispid = dispid; } return celt > remaining ? S_FALSE : S_OK; @@ -7888,7 +7885,6 @@ static HRESULT WINAPI HTMLAttributeCollectionEnum_Reset(IEnumVARIANT *iface)
TRACE("(%p)->()\n", This);
- This->iter = 0; This->iter_dispid = DISPID_STARTENUM; return S_OK; } @@ -7944,7 +7940,6 @@ static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection
ret->IEnumVARIANT_iface.lpVtbl = &HTMLAttributeCollectionEnumVtbl; ret->ref = 1; - ret->iter = 0; ret->iter_dispid = DISPID_STARTENUM;
HTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/tests/dom.js | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/dlls/mshtml/tests/dom.js b/dlls/mshtml/tests/dom.js index 256cab60d7c..300e22cd684 100644 --- a/dlls/mshtml/tests/dom.js +++ b/dlls/mshtml/tests/dom.js @@ -147,9 +147,18 @@ async_test("iframe_location", function() { iframe.onload = function() { ok(iframe.contentWindow.location.pathname === "/emptyfile", "path = " + iframe.contentWindow.location.pathname); + ok(iframe.contentWindow.Image !== undefined, "Image is undefined"); + ok(iframe.contentWindow.VBArray !== undefined, "VBArray is undefined"); + iframe.contentWindow.Image = undefined; + iframe.contentWindow.VBArray = undefined; + iframe.contentWindow.foobar = 1234; iframe.onload = function () { ok(iframe.contentWindow.location.pathname === "/empty/file", "path = " + iframe.contentWindow.location.pathname); + ok(iframe.contentWindow.Image !== undefined, "Image is undefined (2)"); + ok(iframe.contentWindow.VBArray !== undefined, "VBArray is undefined (2)"); + ok(!Object.prototype.hasOwnProperty.call(iframe.contentWindow, "foobar"), + "contentWindow has foobar"); next_test(); } iframe.src = "empty/file";
This merge request was approved by Jacek Caban.