Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- 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 96a776d..4605fda 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 d566223..9db1b4f 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() {