msxml3: Filter unsupported child nodes in insertBefore() for elements.

This commit is contained in:
Nikolay Sivov 2013-03-03 21:20:13 +04:00 committed by Alexandre Julliard
parent ce4291c513
commit 2d5c9f4f46
2 changed files with 26 additions and 4 deletions

View File

@ -301,13 +301,29 @@ static HRESULT WINAPI domelem_get_attributes(
static HRESULT WINAPI domelem_insertBefore(
IXMLDOMElement *iface,
IXMLDOMNode* newNode, VARIANT refChild,
IXMLDOMNode** outOldNode)
IXMLDOMNode** old_node)
{
domelem *This = impl_from_IXMLDOMElement( iface );
DOMNodeType type;
HRESULT hr;
TRACE("(%p)->(%p %s %p)\n", This, newNode, debugstr_variant(&refChild), outOldNode);
TRACE("(%p)->(%p %s %p)\n", This, newNode, debugstr_variant(&refChild), old_node);
return node_insert_before(&This->node, newNode, &refChild, outOldNode);
hr = IXMLDOMNode_get_nodeType(newNode, &type);
if (hr != S_OK) return hr;
TRACE("new node type %d\n", type);
switch (type)
{
case NODE_DOCUMENT:
case NODE_DOCUMENT_TYPE:
case NODE_ENTITY:
case NODE_NOTATION:
if (old_node) *old_node = NULL;
return E_FAIL;
default:
return node_insert_before(&This->node, newNode, &refChild, old_node);
}
}
static HRESULT WINAPI domelem_replaceChild(

View File

@ -4,7 +4,7 @@
* Copyright 2005 Mike McCormack for CodeWeavers
* Copyright 2007-2008 Alistair Leslie-Hughes
* Copyright 2010-2011 Adam Martinson for CodeWeavers
* Copyright 2010-2012 Nikolay Sivov for CodeWeavers
* Copyright 2010-2013 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -8484,6 +8484,12 @@ static void test_insertBefore(void)
todo_wine EXPECT_REF(elem2, 2);
/* document to element */
V_VT(&v) = VT_DISPATCH;
V_DISPATCH(&v) = NULL;
hr = IXMLDOMElement_insertBefore(elem1, (IXMLDOMNode*)doc, v, NULL);
ok(hr == E_FAIL, "got 0x%08x\n", hr);
V_VT(&v) = VT_DISPATCH;
V_DISPATCH(&v) = NULL;
node = NULL;