Commit 514e65c1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use custom VT_BSTR to VT_BOOL conversion in InvokeEx implementation.

parent 4d469b55
......@@ -927,6 +927,16 @@ static HRESULT change_type(VARIANT *dst, VARIANT *src, VARTYPE vt, IServiceProvi
}
}
switch(vt) {
case VT_BOOL:
if(V_VT(src) == VT_BSTR) {
V_VT(dst) = VT_BOOL;
V_BOOL(dst) = V_BSTR(src) && *V_BSTR(src) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
break;
}
return VariantChangeType(dst, src, 0, vt);
}
......
......@@ -98,6 +98,24 @@ function test_clone_node() {
ok(cloned.style.filter === "alpha(opacity=50)", "cloned.style.filter = " + cloned.style.filter);
}
function test_setAttribute() {
var input;
document.body.innerHTML = '<input id="inputid"></input>';
input = document.getElementById("inputid");
ok(input.checked === false, "input.checked = " + input.checked);
input.setAttribute("checked", "test");
ok(input.checked === true, "input.checked = " + input.checked);
input.setAttribute("checked", 0);
ok(input.checked === false, "input.checked = " + input.checked);
input.setAttribute("checked", "");
ok(input.checked === false, "input.checked = " + input.checked);
}
function test_getter_call() {
document.body.innerHTML = '<div id="divid"></div>';
......@@ -133,7 +151,7 @@ function test_override_functions() {
var globalVar = false;
function runTest() {
function runTests() {
obj = new Object();
ok(obj === window.obj, "obj !== window.obj");
......@@ -147,11 +165,20 @@ function runTest() {
test_document_name_as_index();
test_remove_style_attribute();
test_getter_call();
test_setAttribute();
test_override_functions();
var r = window.execScript("globalVar = true;");
ok(r === undefined, "execScript returned " + r);
ok(globalVar === true, "globalVar = " + globalVar);
}
function runTest() {
try {
runTests();
}catch(e) {
ok(false, "got exception");
}
external.reportSuccess();
}
......
......@@ -2028,6 +2028,62 @@ static void test_arg_conv(IHTMLWindow2 *window)
IDispatchEx_Release(dispex);
}
#define test_elem_disabled(a,b) _test_elem_disabled(__LINE__,a,b)
static void _test_elem_disabled(unsigned line, IHTMLElement *elem, VARIANT_BOOL exb)
{
IHTMLElement3 *elem3;
VARIANT_BOOL b = 100;
HRESULT hres;
hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement3, (void**)&elem3);
ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLElement3 iface: %08x\n", hres);
hres = IHTMLElement3_get_disabled(elem3, &b);
ok_(__FILE__,line)(hres == S_OK, "get_disabled failed: %08x\n", hres);
ok_(__FILE__,line)(b == exb, "disabled = %x, expected %x\n", b, exb);
IHTMLElement3_Release(elem3);
}
static void test_default_arg_conv(IHTMLWindow2 *window)
{
IHTMLDocument2 *doc;
IDispatchEx *dispex;
IHTMLElement *elem;
VARIANT v;
HRESULT hres;
hres = IHTMLWindow2_get_document(window, &doc);
ok(hres == S_OK, "get_document failed: %08x\n", hres);
hres = IHTMLDocument2_get_body(doc, &elem);
IHTMLDocument2_Release(doc);
ok(hres == S_OK, "get_body failed: %08x\n", hres);
hres = IHTMLElement_QueryInterface(elem, &IID_IDispatchEx, (void**)&dispex);
ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
test_elem_disabled(elem, VARIANT_FALSE);
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = a2bstr("test");
hres = dispex_propput(dispex, DISPID_IHTMLELEMENT3_DISABLED, 0, &v, NULL);
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
SysFreeString(V_BSTR(&v));
test_elem_disabled(elem, VARIANT_TRUE);
V_VT(&v) = VT_I4;
V_BSTR(&v) = 0;
hres = dispex_propput(dispex, DISPID_IHTMLELEMENT3_DISABLED, 0, &v, NULL);
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
test_elem_disabled(elem, VARIANT_FALSE);
IHTMLElement_Release(elem);
IDispatchEx_Release(dispex);
}
static void test_script_run(void)
{
IDispatchEx *document, *dispex;
......@@ -2198,6 +2254,7 @@ static void test_script_run(void)
test_nextdispid(dispex);
test_arg_conv(window);
test_default_arg_conv(window);
IHTMLWindow2_Release(window);
tmp = a2bstr("test");
......
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