[PATCH 01/14] mshtml: Retry with VT_NULL when removing an attribute.

Gabriel Ivăncescu gabrielopcode at gmail.com
Tue Nov 16 08:29:20 CST 2021


set_event_handler fails with "attempt to set to VT_EMPTY in quirks mode"
intentionally. But it shouldn't throw when removing the builtin attribute.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/mshtml/dispex.c              |  5 ++++
 dlls/mshtml/tests/documentmode.js | 40 +++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c
index 96a776d..bddb0e3 100644
--- a/dlls/mshtml/dispex.c
+++ b/dlls/mshtml/dispex.c
@@ -1466,6 +1466,11 @@ HRESULT remove_attribute(DispatchEx *This, DISPID id, VARIANT_BOOL *success)
 
         V_VT(&var) = VT_EMPTY;
         hres = builtin_propput(This, func, &dp, NULL);
+        if(hres == E_NOTIMPL) {
+            /* Setting event handlers to VT_EMPTY fails in quirks mode */
+            V_VT(&var) = VT_NULL;
+            hres = builtin_propput(This, func, &dp, NULL);
+        }
         if(FAILED(hres))
             return hres;
 
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js
index d566223..c197f9b 100644
--- a/dlls/mshtml/tests/documentmode.js
+++ b/dlls/mshtml/tests/documentmode.js
@@ -1087,6 +1087,46 @@ 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 < 9).
+    ok(r === (v < 9 ? false : undefined), "removeAttribute returned " + r);
+    todo_wine_if(v < 9).
+    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);
+
+    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);
 });
 
 sync_test("__proto__", function() {
-- 
2.31.1




More information about the wine-devel mailing list