Commit c1464f8a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Fix return value for IXMLDOMNode_put_nodeValue() for unsupported types.

parent 5262c570
......@@ -327,23 +327,11 @@ static HRESULT WINAPI xmlnode_put_nodeValue(
{
xmlnode *This = impl_from_IXMLDOMNode( iface );
HRESULT hr;
xmlChar *str = NULL;
VARIANT string_value;
TRACE("%p type(%d)\n", This, This->node->type);
VariantInit(&string_value);
hr = VariantChangeType(&string_value, &value, 0, VT_BSTR);
if(FAILED(hr))
{
VariantClear(&string_value);
WARN("Couldn't convert to VT_BSTR\n");
return hr;
}
hr = S_FALSE;
/* Document, Document Fragment, Document Type, Element,
Entity, Entity Reference, Notation aren't supported. */
Entity, Entity Reference, Notation aren't supported. */
switch ( This->node->type )
{
case XML_ATTRIBUTE_NODE:
......@@ -351,20 +339,33 @@ static HRESULT WINAPI xmlnode_put_nodeValue(
case XML_COMMENT_NODE:
case XML_PI_NODE:
case XML_TEXT_NODE:
{
{
VARIANT string_value;
xmlChar *str;
VariantInit(&string_value);
hr = VariantChangeType(&string_value, &value, 0, VT_BSTR);
if(FAILED(hr))
{
VariantClear(&string_value);
WARN("Couldn't convert to VT_BSTR\n");
return hr;
}
str = xmlChar_from_wchar(V_BSTR(&string_value));
VariantClear(&string_value);
xmlNodeSetContent(This->node, str);
heap_free(str);
hr = S_OK;
break;
}
}
default:
/* Do nothing for unsupported types. */
hr = E_FAIL;
break;
}
VariantClear(&string_value);
return hr;
}
......
......@@ -5000,6 +5000,73 @@ static void test_TransformWithLoadingLocalFile(void)
free_bstrs();
}
static void test_put_nodeValue(void)
{
IXMLDOMDocument *doc;
IXMLDOMEntityReference *entityref;
IXMLDOMNode *node;
HRESULT hr;
VARIANT data, type;
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
if( hr != S_OK )
return;
/* test for unsupported types */
/* NODE_DOCUMENT */
hr = IXMLDOMDocument_QueryInterface(doc, &IID_IXMLDOMNode, (void**)&node);
ok(hr == S_OK, "ret %08x\n", hr );
V_VT(&data) = VT_BSTR;
V_BSTR(&data) = _bstr_("one two three");
hr = IXMLDOMNode_put_nodeValue(node, data);
ok(hr == E_FAIL, "ret %08x\n", hr );
IXMLDOMNode_Release(node);
/* NODE_DOCUMENT_FRAGMENT */
V_VT(&type) = VT_I1;
V_I1(&type) = NODE_DOCUMENT_FRAGMENT;
hr = IXMLDOMDocument_createNode(doc, type, _bstr_("test"), NULL, &node);
ok(hr == S_OK, "ret %08x\n", hr );
V_VT(&data) = VT_BSTR;
V_BSTR(&data) = _bstr_("one two three");
hr = IXMLDOMNode_put_nodeValue(node, data);
ok(hr == E_FAIL, "ret %08x\n", hr );
IXMLDOMNode_Release(node);
/* NODE_ELEMENT */
V_VT(&type) = VT_I1;
V_I1(&type) = NODE_ELEMENT;
hr = IXMLDOMDocument_createNode(doc, type, _bstr_("test"), NULL, &node);
ok(hr == S_OK, "ret %08x\n", hr );
V_VT(&data) = VT_BSTR;
V_BSTR(&data) = _bstr_("one two three");
hr = IXMLDOMNode_put_nodeValue(node, data);
ok(hr == E_FAIL, "ret %08x\n", hr );
IXMLDOMNode_Release(node);
/* NODE_ENTITY_REFERENCE */
hr = IXMLDOMDocument_createEntityReference(doc, _bstr_("ref"), &entityref);
ok(hr == S_OK, "ret %08x\n", hr );
V_VT(&data) = VT_BSTR;
V_BSTR(&data) = _bstr_("one two three");
hr = IXMLDOMEntityReference_put_nodeValue(node, data);
ok(hr == E_FAIL, "ret %08x\n", hr );
hr = IXMLDOMEntityReference_QueryInterface(entityref, &IID_IXMLDOMNode, (void**)&node);
ok(hr == S_OK, "ret %08x\n", hr );
V_VT(&data) = VT_BSTR;
V_BSTR(&data) = _bstr_("one two three");
hr = IXMLDOMNode_put_nodeValue(node, data);
ok(hr == E_FAIL, "ret %08x\n", hr );
IXMLDOMNode_Release(node);
IXMLDOMEntityReference_Release(entityref);
free_bstrs();
IXMLDOMDocument_Release(doc);
}
START_TEST(domdoc)
{
HRESULT r;
......@@ -5030,6 +5097,7 @@ START_TEST(domdoc)
test_FormattingXML();
test_NodeTypeValue();
test_TransformWithLoadingLocalFile();
test_put_nodeValue();
CoUninitialize();
}
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