Commit f1958583 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Handle VT_DISPATCH in variant_to_nsstr.

Some javascript libraries such as prototype.js use this (by setting to an array) to examine setAttribute quirks. Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent ce1b3f5f
......@@ -1013,7 +1013,8 @@ HRESULT variant_to_nsstr(VARIANT *v, BOOL hex_int, nsAString *nsstr)
nsAString_Init(nsstr, buf);
break;
case VT_R8: {
case VT_R8:
case VT_DISPATCH: {
VARIANT strv;
HRESULT hres;
......
......@@ -1088,6 +1088,72 @@ sync_test("elem_attr", function() {
r = elem.getAttribute("className");
ok(r === "cls3", "className attr = " + r);
var arr = [3];
elem.setAttribute("testattr", arr);
r = elem.getAttribute("testattr");
ok(r === (v < 8 ? arr : "3"), "testattr = " + r);
todo_wine_if(v === 8).
ok(elem.testattr === (v < 9 ? arr : undefined), "elem.testattr = " + elem.testattr);
r = elem.removeAttribute("testattr");
ok(r === (v < 9 ? true : undefined), "testattr removeAttribute returned " + r);
ok(elem.testattr === undefined, "removed testattr = " + elem.testattr);
arr[0] = 9;
elem.setAttribute("testattr", "string");
elem.testattr = arr;
r = elem.getAttribute("testattr");
todo_wine_if(v === 8).
ok(r === (v < 8 ? arr : (v < 9 ? "9" : "string")), "testattr = " + r);
ok(elem.testattr === arr, "elem.testattr = " + elem.testattr);
arr[0] = 3;
r = elem.getAttribute("testattr");
todo_wine_if(v === 8).
ok(r === (v < 8 ? arr : (v < 9 ? "3" : "string")), "testattr = " + r);
ok(elem.testattr === arr, "elem.testattr = " + elem.testattr);
r = elem.removeAttribute("testattr");
ok(r === (v < 9 ? true : undefined), "testattr removeAttribute returned " + r);
todo_wine_if(v === 8).
ok(elem.testattr === (v < 9 ? undefined : arr), "removed testattr = " + elem.testattr);
arr.toString = function() { return 42; }
elem.testattr = arr;
r = elem.getAttribute("testattr");
todo_wine_if(v === 8).
ok(r === (v < 8 ? arr : (v < 9 ? "42" : null)), "testattr with custom toString = " + r);
elem.setAttribute("testattr", arr);
r = elem.getAttribute("testattr");
ok(r === (v < 8 ? arr : "42"), "testattr after setAttribute with custom toString = " + r);
ok(elem.testattr === arr, "elem.testattr after setAttribute with custom toString = " + elem.testattr);
r = elem.removeAttribute("testattr");
ok(r === (v < 9 ? true : undefined), "testattr removeAttribute with custom toString returned " + r);
todo_wine_if(v === 8).
ok(elem.testattr === (v < 9 ? undefined : arr), "removed testattr with custom toString = " + elem.testattr);
arr.valueOf = function() { return "arrval"; }
elem.testattr = arr;
r = elem.getAttribute("testattr");
todo_wine_if(v === 8).
ok(r === (v < 8 ? arr : (v < 9 ? "arrval" : null)), "testattr with custom valueOf = " + r);
elem.setAttribute("testattr", arr);
r = elem.getAttribute("testattr");
todo_wine_if(v >= 10).
ok(r === (v < 8 ? arr : (v < 10 ? "arrval" : "42")), "testattr after setAttribute with custom valueOf = " + r);
ok(elem.testattr === arr, "elem.testattr after setAttribute with custom valueOf = " + elem.testattr);
r = elem.removeAttribute("testattr");
ok(r === (v < 9 ? true : undefined), "testattr removeAttribute with custom valueOf returned " + r);
todo_wine_if(v === 8).
ok(elem.testattr === (v < 9 ? undefined : arr), "removed testattr with custom valueOf = " + elem.testattr);
delete arr.valueOf;
delete arr.toString;
elem.setAttribute("id", arr);
r = elem.getAttribute("id");
todo_wine_if(v >= 8 && v < 10).
ok(r === (v < 8 || v >= 10 ? "3" : "[object]"), "id = " + r);
r = elem.removeAttribute("id");
ok(r === (v < 9 ? true : undefined), "id removeAttribute returned " + r);
ok(elem.id === "", "removed id = " + elem.id);
var func = function() { };
elem.onclick = func;
ok(elem.onclick === func, "onclick = " + elem.onclick);
......@@ -1136,6 +1202,17 @@ sync_test("elem_attr", function() {
todo_wine_if(v >= 8).
ok(elem.onclick === null, "removed onclick = " + elem.onclick);
elem.setAttribute("ondblclick", arr);
r = elem.getAttribute("ondblclick");
todo_wine_if(v >= 8 && v < 10).
ok(r === (v < 8 ? arr : (v < 10 ? "[object]" : "3")), "ondblclick = " + r);
r = elem.removeAttribute("ondblclick");
ok(r === (v < 8 ? false : (v < 9 ? true : undefined)), "ondblclick removeAttribute returned " + r);
r = Object.prototype.toString.call(elem.ondblclick);
todo_wine_if(v >= 9).
ok(r === (v < 8 ? "[object Array]" : (v < 9 ? "[object Object]" : (v < 11 ? "[object Null]" : "[object Function]"))),
"removed ondblclick Object.toString returned " + r);
elem.setAttribute("ondblclick", "string");
r = elem.getAttribute("ondblclick");
ok(r === "string", "ondblclick string = " + r);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment