Gabriel Ivăncescu : mshtml: Clear the string dprop associated with the builtin attribute when removing it.
Alexandre Julliard
julliard at winehq.org
Wed Nov 17 16:27:59 CST 2021
Module: wine
Branch: master
Commit: 6b2c20c6a1aa046c5f0317221b52609bcaa11295
URL: https://source.winehq.org/git/wine.git/?a=commit;h=6b2c20c6a1aa046c5f0317221b52609bcaa11295
Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date: Tue Nov 16 19:58:16 2021 +0200
mshtml: Clear the string dprop associated with the builtin attribute when removing it.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mshtml/dispex.c | 13 ++++++---
dlls/mshtml/tests/documentmode.js | 56 +++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c
index 96a776d9594..4605fdac0f0 100644
--- a/dlls/mshtml/dispex.c
+++ b/dlls/mshtml/dispex.c
@@ -1463,13 +1463,18 @@ HRESULT remove_attribute(DispatchEx *This, DISPID id, VARIANT_BOOL *success)
*success = VARIANT_TRUE;
return S_OK;
}
+ *success = VARIANT_TRUE;
V_VT(&var) = VT_EMPTY;
hres = builtin_propput(This, func, &dp, NULL);
- if(FAILED(hres))
- return hres;
-
- *success = VARIANT_TRUE;
+ if(FAILED(hres)) {
+ VARIANT *ref;
+ hres = dispex_get_dprop_ref(This, func->name, FALSE, &ref);
+ if(FAILED(hres) || V_VT(ref) != VT_BSTR)
+ *success = VARIANT_FALSE;
+ else
+ VariantClear(ref);
+ }
return S_OK;
}
default:
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js
index d5662239bfa..9db1b4f686b 100644
--- a/dlls/mshtml/tests/documentmode.js
+++ b/dlls/mshtml/tests/documentmode.js
@@ -1087,6 +1087,62 @@ sync_test("elem_attr", function() {
ok(r === "cls2", "class attr = " + r);
r = elem.getAttribute("className");
ok(r === "cls3", "className attr = " + r);
+
+ var func = function() { };
+ elem.onclick = func;
+ ok(elem.onclick === func, "onclick = " + elem.onclick);
+ r = elem.getAttribute("onclick");
+ ok(r === (v < 8 ? func : null), "onclick attr = " + r);
+ r = elem.removeAttribute("onclick");
+ todo_wine_if(v === 8).
+ ok(r === (v < 9 ? false : undefined), "removeAttribute returned " + r);
+ todo_wine_if(v === 8).
+ ok(elem.onclick === (v != 8 ? func : null), "removed onclick = " + elem.onclick);
+
+ elem.onclick_test = func;
+ ok(elem.onclick_test === func, "onclick_test = " + elem.onclick_test);
+ r = elem.getAttribute("onclick_test");
+ todo_wine_if(v === 8).
+ ok(r === (v < 8 ? func : (v < 9 ? func.toString() : null)), "onclick_test attr = " + r);
+
+ elem.setAttribute("onclick", "test");
+ r = elem.getAttribute("onclick");
+ ok(r === "test", "onclick attr after setAttribute = " + r);
+ r = elem.removeAttribute("onclick");
+ ok(r === (v < 9 ? true : undefined), "removeAttribute after setAttribute returned " + r);
+
+ /* IE11 returns an empty function, which we can't check directly */
+ todo_wine_if(v >= 8).
+ ok((v < 11) ? (elem.onclick === null) : (elem.onclick !== func), "removed onclick after setAttribute = " + elem.onclick);
+
+ r = Object.prototype.toString.call(elem.onclick);
+ todo_wine_if(v >= 8 && v < 11).
+ ok(r === (v < 9 ? "[object Object]" : (v < 11 ? "[object Null]" : "[object Function]")),
+ "removed onclick after setAttribute Object.toString returned " + r);
+
+ elem.setAttribute("onclick", "string");
+ r = elem.getAttribute("onclick");
+ ok(r === "string", "onclick attr after setAttribute = " + r);
+ elem.onclick = func;
+ ok(elem.onclick === func, "onclick = " + elem.onclick);
+ r = elem.getAttribute("onclick");
+ todo_wine_if(v === 8).
+ ok(r === (v < 8 ? func : (v < 9 ? null : "string")), "onclick attr = " + r);
+ elem.onclick = "test";
+ r = elem.getAttribute("onclick");
+ todo_wine_if(v === 8).
+ ok(r === (v < 9 ? "test" : "string"), "onclick attr = " + r);
+ r = elem.removeAttribute("onclick");
+ ok(r === (v < 9 ? true : undefined), "removeAttribute returned " + r);
+ todo_wine_if(v >= 8).
+ ok(elem.onclick === null, "removed onclick = " + elem.onclick);
+
+ elem.setAttribute("ondblclick", "string");
+ r = elem.getAttribute("ondblclick");
+ ok(r === "string", "ondblclick string = " + r);
+ r = elem.removeAttribute("ondblclick");
+ ok(r === (v < 9 ? true : undefined), "ondblclick string removeAttribute returned " + r);
+ ok(elem.ondblclick === null, "removed ondblclick string = " + elem.ondblclick);
});
sync_test("__proto__", function() {
More information about the wine-cvs
mailing list