From 30e5e9367df70b69041bb88fece87d32a4251930 Mon Sep 17 00:00:00 2001 From: Jefferson Carpenter Date: Mon, 31 May 2021 20:06:19 +0000 Subject: [PATCH 2/4] msxml3/tests: Test for disabled element methods with writer domdoc dest. Signed-off-by: Jefferson Carpenter --- dlls/msxml3/tests/saxreader.c | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index 1bd9787cb92..53e2af016f4 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -4918,6 +4918,58 @@ static void check_domnode_methods_disabled(IXMLDOMDocument *locked_doc, IXMLDOMN IXMLDOMDocument_Release(stylesheet); } +static void check_domelement_methods_disabled(IXMLDOMElement *locked_element) +{ + HRESULT hr; + BSTR bstr; + BSTR some_attribute; + VARIANT variant; + IXMLDOMAttribute *attribute_node; + IXMLDOMNodeList *node_list; + + some_attribute = _bstr_("some-attribute"); + + bstr = (void*)0xdeadbeef; + hr = IXMLDOMElement_get_tagName(locked_element, &bstr); + ok(hr == S_OK, "%p: Unexpected hr %#x.\n", locked_element, hr); + ok(bstr != (void*)0xdeadbeef, "%p: Got %p.\n", locked_element, bstr); + ok(!lstrcmpW(bstr, L"BankAccount"), "%p: Incorrect tag name: %s.\n", locked_element, wine_dbgstr_w(bstr)); + SysFreeString(bstr); + + V_VT(&variant) = VT_EMPTY; + hr = IXMLDOMElement_getAttribute(locked_element, some_attribute, &variant); + ok(hr == S_FALSE, "%p: Unexpected hr %#x.\n", locked_element, hr); + ok(V_VT(&variant) == VT_NULL, "%p: Got %d.\n", locked_element, V_VT(&variant)); + + V_VT(&variant) = VT_BSTR; + V_BSTR(&variant) = _bstr_("some-value"); + hr = IXMLDOMElement_setAttribute(locked_element, some_attribute, variant); + ok(hr == E_FAIL, "%p: Unexpected hr %#x.\n", locked_element, hr); + + hr = IXMLDOMElement_removeAttribute(locked_element, some_attribute); + ok(hr == E_FAIL, "%p: Unexpected hr %#x.\n", locked_element, hr); + + attribute_node = (void*)0xdeadbeef; + hr = IXMLDOMElement_getAttributeNode(locked_element, some_attribute, &attribute_node); + ok(hr == S_FALSE, "%p: Unexpected hr %#x.\n", locked_element, hr); + ok(attribute_node != (void*)0xdeadbeef, "%p: Got %p.\n", locked_element, attribute_node); + + hr = IXMLDOMElement_setAttributeNode(locked_element, NULL, NULL); + ok(hr == E_FAIL, "%p: Unexpected hr %#x.\n", locked_element, hr); + + hr = IXMLDOMElement_removeAttributeNode(locked_element, NULL, NULL); + ok(hr == E_FAIL, "%p: Unexpected hr %#x.\n", locked_element, hr); + + node_list = (void*)0xdeadbeef; + hr = IXMLDOMElement_getElementsByTagName(locked_element, _bstr_("some_tag_name"), &node_list); + todo_wine ok(hr == E_PENDING, "%p: Unexpected hr %#x.\n", locked_element, hr); + ok(node_list != (void*)0xdeadbeef, "%p: Got %p.\n", locked_element, node_list); + if (node_list) IXMLDOMNodeList_Release(node_list); + + hr = IXMLDOMElement_normalize(locked_element); + ok(hr == E_FAIL, "%p: Unexpected hr %#x.\n", locked_element, hr); +} + static void test_mxwriter_domdoc_startDocument_disables_domdoc_methods(void) { HRESULT hr; @@ -4937,6 +4989,8 @@ static void test_mxwriter_domdoc_startDocument_disables_domdoc_methods(void) IXMLDOMText *text = NULL; IXMLDOMComment *comment = NULL; IXMLDOMCDATASection *cdata_section = NULL; + /* for disabled element methods */ + IXMLDOMElement *element = NULL; IXMLDOMDocument2 *domdoc2; IXMLDOMDocument3 *domdoc3; @@ -5054,9 +5108,32 @@ static void test_mxwriter_domdoc_startDocument_disables_domdoc_methods(void) if (import_text_node) check_domnode_methods_disabled(domdoc, import_text_node, DOMNodeDisabled_imported_text); + /* Call IXMLDOMElement methods on element. */ + element = NULL; + if (element_node) { + hr = IXMLDOMNode_QueryInterface(element_node, &IID_IXMLDOMElement, (void**)&element); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + } + if (element) { + check_domelement_methods_disabled(element); + IXMLDOMElement_Release(element); + } + + element = NULL; + if (import_element_node) { + hr = IXMLDOMNode_QueryInterface(import_element_node, &IID_IXMLDOMElement, (void**)&element); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + } + if (element) { + check_domelement_methods_disabled(element); + IXMLDOMElement_Release(element); + } + + if (import_text_node) IXMLDOMNode_Release(import_text_node); if (import_element_node) IXMLDOMNode_Release(import_element_node); if (text_node) IXMLDOMNode_Release(text_node); + if (element_node) IXMLDOMNode_Release(element_node); IXMLDOMDocument3_Release(domdoc3); IXMLDOMDocument2_Release(domdoc2); IXMLDOMDocument_Release(domdoc); -- 2.26.2