From 2c2f576163595d7824886ef3cb95953e151cd3b1 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 28 Nov 2014 16:19:42 +0100 Subject: [PATCH] mshtml: Added more attribute and IDispatchEx tests. --- dlls/mshtml/tests/jstest.html | 110 +++++++++++++++++++++++++++++++++- dlls/mshtml/tests/script.c | 19 ++++++ 2 files changed, 126 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/tests/jstest.html b/dlls/mshtml/tests/jstest.html index 792e28e37cb..39cdae5292a 100644 --- a/dlls/mshtml/tests/jstest.html +++ b/dlls/mshtml/tests/jstest.html @@ -5,6 +5,10 @@ function ok(b,m) { return external.ok(b, m); } +function broken(expr) { + return external.broken(expr); +} + function test_removeAttribute(e) { ok(e.removeAttribute('nonexisting') === false, "removeAttribute('nonexisting') didn't return false"); @@ -98,11 +102,13 @@ function test_clone_node() { ok(cloned.style.filter === "alpha(opacity=50)", "cloned.style.filter = " + cloned.style.filter); } -function test_setAttribute() { - var input; +function test_attrs() { + var input, s, x, f, b; document.body.innerHTML = ''; input = document.getElementById("inputid"); + s = input.style; + f = input.fireEvent; ok(input.checked === false, "input.checked = " + input.checked); input.setAttribute("checked", "test"); @@ -113,6 +119,104 @@ function test_setAttribute() { input.setAttribute("checked", ""); ok(input.checked === false, "input.checked = " + input.checked); + + input.setAttribute("Checked", 1, 0); + ok(input.checked === true, "input.checked = " + input.checked); + ok(!("Checked" in input), "Checked added to input"); + + input.setAttribute("checked", 0, 0); + input.setAttribute("Checked", 1, 1); + ok(input.checked === false, "input.checked = " + input.checked); + ok("Checked" in input, "checked not added to input"); + ok(input.Checked === 1, "input.Checked = " + input.Checked); + + input.removeAttribute("Checked", 1); + ok(!("Checked" in input), "Checked is still in input"); + ok(input.checked === false, "input.checked = " + input.checked); + + input.setAttribute("checked", 1, 0); + input.setAttribute("Checked", 0); + ok(input.checked === true, "input.checked = " + input.checked); + ok("Checked" in input, "checked not added to input"); + ok(input.Checked === 0, "input.Checked = " + input.Checked); + + input.setAttribute("Checked", 2, 2); + ok(input.Checked === 0, "input.Checked = " + input.Checked); + input.setAttribute("Checked", 3, 3); + ok(input.Checked === 3, "input.Checked = " + input.Checked); + + x = input.getAttribute("style"); + ok(x === s, "getAttribute('style') = " + x); + ok(s.cssText === "", "s.cssText = " + s.cssText); + + input.setAttribute("style", "display: none"); + x = input.getAttribute("style"); + ok(x === s, "getAttribute('style') = " + x); + ok(s.cssText === "", "s.cssText = " + s.cssText); + ok(s.display === "", "s.display = " + s.display); + + s.display = "none"; + ok(s.cssText != "", "s.cssText = " + s.cssText); + ok(s.display === "none", "s.display = " + s.display); + input.setAttribute("style", ""); + x = input.getAttribute("style"); + ok(x === s, "getAttribute('style') = " + x); + ok(s.cssText != "", "s.cssText = " + s.cssText); + ok(s.display === "none", "s.display = " + s.display); + + input.setAttribute("style", null); + x = input.getAttribute("style"); + ok(input.style === s, "input.style = " + input.style); + ok(x === s, "getAttribute('style') = " + x); + ok(s.cssText != "", "s.cssText = " + s.cssText); + ok(s.display === "none", "s.display = " + s.display); + + x = input.getAttribute("fireEvent"); + ok(x === input.fireEvent, "input.getAttribute('fireEvent') = " + x); + + input.setAttribute("fireEvent", 3); + ok(input.fireEvent === 3, "input.fireEvent = " + input.fireEvent); + x = input.getAttribute("fireEvent"); + ok(x === 3, "input.getAttribute('fireEvent') = " + x); + + b = input.removeAttribute("style"); + ok(b === true, "removeAttribute('style') failed"); + ok(input.style === s, "input.style = " + input.style); + x = input.getAttribute("style"); + ok(x === s, "getAttribute('style') = " + x); + ok(s.display === "", "s.display = " + s.display); + ok(s.cssText === "", "s.cssText = " + s.cssText); + b = input.removeAttribute("style"); + ok(b === true, "removeAttribute('style') failed"); + + b = false; + try { + input.setAttribute("tagName", "xxx"); + }catch(e) { + b = true; + } + ok(b, "Expected exception on setAttribute(tagName)"); + + b = false; + try { + input.setAttribute("parentElement", "xxx"); + }catch(e) { + b = true; + } + ok(b, "Expected exception on setAttribute(parentElement)"); + + b = input.removeAttribute("fireEvent"); + ok(b === true, "removeAttribute(fireEvent) failed"); + ok(input.fireEvent === f, "input.fireEvent = " + input.fireEvent); + x = input.getAttribute("fireEvent"); + ok(x === f, "input.getAttribute('fireEvent') = " + x); + b = input.removeAttribute("fireEvent"); + ok(b === false || broken(b === true), "removeAttribute(fireEvent) returned " + b); + + input.fireEvent = 3; + x = input.getAttribute("fireEvent"); + ok(x === 3, "input.getAttribute('fireEvent') = " + x); + ok(input.fireEvent === 3, "input.fireEvent' = " + input.fireEvent); } function test_attribute_collection() { @@ -239,7 +343,7 @@ function runTests() { test_document_name_as_index(); test_remove_style_attribute(); test_getter_call(); - test_setAttribute(); + test_attrs(); test_attribute_collection(); test_arg_conv(); test_override_functions(); diff --git a/dlls/mshtml/tests/script.c b/dlls/mshtml/tests/script.c index 9681fd6804b..b92b66b0887 100644 --- a/dlls/mshtml/tests/script.c +++ b/dlls/mshtml/tests/script.c @@ -146,6 +146,7 @@ DEFINE_EXPECT(ChangeType); #define DISPID_EXTERNAL_TRACE 0x300001 #define DISPID_EXTERNAL_REPORTSUCCESS 0x300002 #define DISPID_EXTERNAL_TODO_WINE_OK 0x300003 +#define DISPID_EXTERNAL_BROKEN 0x300004 static const GUID CLSID_TestScript = {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x07,0x46}}; @@ -594,6 +595,10 @@ static HRESULT WINAPI externalDisp_GetDispID(IDispatchEx *iface, BSTR bstrName, *pid = DISPID_EXTERNAL_TODO_WINE_OK; return S_OK; } + if(!strcmp_wa(bstrName, "broken")) { + *pid = DISPID_EXTERNAL_BROKEN; + return S_OK; + } ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName)); return DISP_E_UNKNOWNNAME; @@ -673,6 +678,20 @@ static HRESULT WINAPI externalDisp_InvokeEx(IDispatchEx *iface, DISPID id, LCID return S_OK; + case DISPID_EXTERNAL_BROKEN: + ok(wFlags == INVOKE_FUNC || wFlags == (INVOKE_FUNC|INVOKE_PROPERTYGET), "wFlags = %x\n", wFlags); + ok(pdp != NULL, "pdp == NULL\n"); + ok(pdp->rgvarg != NULL, "rgvarg == NULL\n"); + ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n"); + ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs); + ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(pei != NULL, "pei == NULL\n"); + + ok(V_VT(pdp->rgvarg) == VT_BOOL, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg)); + V_VT(pvarRes) = VT_BOOL; + V_BOOL(pvarRes) = broken(V_BOOL(pdp->rgvarg)) ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; + default: ok(0, "unexpected call\n"); return E_NOTIMPL;