From 5bbc8984fe1d12182b27d5447e129790752c16d2 Mon Sep 17 00:00:00 2001 From: Jefferson Carpenter Date: Mon, 31 May 2021 20:04:04 +0000 Subject: [PATCH 1/4] msxml3/tests: Test for disabled node methods with writer domdoc dest. Signed-off-by: Jefferson Carpenter --- dlls/msxml3/tests/saxreader.c | 619 ++++++++++++++++++++++++++++++++++ 1 file changed, 619 insertions(+) diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index e401aafc87d..1bd9787cb92 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -4446,6 +4446,624 @@ static void test_mxwriter_stream(void) free_bstrs(); } +/* Indicates the kind of dom node tested for disabled methods */ +enum DOMNodeDisabledTest +{ + DOMNodeDisabled_domdoc, + DOMNodeDisabled_domdoc_fragment, + DOMNodeDisabled_element, + DOMNodeDisabled_text, + DOMNodeDisabled_created_text, + DOMNodeDisabled_created_comment, + DOMNodeDisabled_created_cdata_section, + DOMNodeDisabled_imported_element, + DOMNodeDisabled_imported_text, +}; + +static void check_domnode_methods_disabled(IXMLDOMDocument *locked_doc, IXMLDOMNode *locked_node, enum DOMNodeDisabledTest node_kind) +{ + HRESULT hr; + BSTR bstr; + IXMLDOMDocument *stylesheet; + VARIANT variant; + DOMNodeType type; + IXMLDOMDocument *document; + IXMLDOMNode *dom_node; + IXMLDOMNode *out_node; + IXMLDOMText *text; + IXMLDOMNodeList *node_list; + IXMLDOMNamedNodeMap *attributes; + VARIANT_BOOL variant_bool; + + hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void **)&stylesheet); + ok(hr == S_OK, "Failed to create a stylesheet, hr %#x.\n", hr); + hr = IXMLDOMDocument_loadXML(stylesheet, _bstr_("" + ""), &variant_bool); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + + bstr = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_nodeName(locked_node, &bstr); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(bstr != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, bstr); + SysFreeString(bstr); + + V_VT(&variant) = VT_NULL; + hr = IXMLDOMNode_get_nodeValue(locked_node, &variant); + switch (node_kind) { + case DOMNodeDisabled_text: + case DOMNodeDisabled_created_text: + case DOMNodeDisabled_created_comment: + case DOMNodeDisabled_created_cdata_section: + case DOMNodeDisabled_imported_text: + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(V_VT(&variant) == VT_BSTR, "DOMNodeDisabledTest(%d): Got %d.\n", node_kind, V_VT(&variant)); + SysFreeString(V_BSTR(&variant)); + break; + default: + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + break; + } + + V_VT(&variant) = VT_BSTR; + V_BSTR(&variant) = _bstr_("some value"); + hr = IXMLDOMNode_put_nodeValue(locked_node, variant); + todo_wine_if( + node_kind == DOMNodeDisabled_element || + node_kind == DOMNodeDisabled_created_text || + node_kind == DOMNodeDisabled_created_comment || + node_kind == DOMNodeDisabled_created_cdata_section || + node_kind == DOMNodeDisabled_imported_element || + node_kind == DOMNodeDisabled_imported_text + ) ok(hr == E_FAIL, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + + type = NODE_INVALID; + hr = IXMLDOMNode_get_nodeType(locked_node, &type); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + switch (node_kind) { + case DOMNodeDisabled_domdoc: + ok(type == NODE_DOCUMENT, "DOMNodeDisabledTest(%d): Got %d.\n", node_kind, type); + break; + case DOMNodeDisabled_domdoc_fragment: + ok(type == NODE_DOCUMENT_FRAGMENT, "DOMNodeDisabledTest(%d): Got %d.\n", node_kind, type); + break; + case DOMNodeDisabled_element: + case DOMNodeDisabled_imported_element: + ok(type == NODE_ELEMENT, "DOMNodeDisabledTest(%d): Got %d.\n", node_kind, type); + break; + case DOMNodeDisabled_created_comment: + ok(type == NODE_COMMENT, "DOMNodeDisabledTest(%d): Got %d.\n", node_kind, type); + break; + case DOMNodeDisabled_created_cdata_section: + ok(type == NODE_CDATA_SECTION, "DOMNodeDisabledTest(%d): Got %d.\n", node_kind, type); + break; + default: + ok(type == NODE_TEXT, "DOMNodeDisabledTest(%d): Got %d.\n", node_kind, type); + break; + } + + dom_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_parentNode(locked_node, &dom_node); + ok(dom_node != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, dom_node); + switch (node_kind) { + case DOMNodeDisabled_element: + case DOMNodeDisabled_text: + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + IXMLDOMNode_Release(dom_node); + break; + default: + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + break; + } + + node_list = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_childNodes(locked_node, &node_list); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(node_list != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, node_list); + IXMLDOMNodeList_Release(node_list); + + dom_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_firstChild(locked_node, &dom_node); + ok(dom_node != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, dom_node); + switch (node_kind) { + case DOMNodeDisabled_domdoc: + case DOMNodeDisabled_element: + case DOMNodeDisabled_imported_element: + todo_wine ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + if (dom_node) IXMLDOMNode_Release(dom_node); + break; + default: + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + break; + } + + dom_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_lastChild(locked_node, &dom_node); + ok(dom_node != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, dom_node); + switch (node_kind) { + case DOMNodeDisabled_domdoc: + case DOMNodeDisabled_element: + case DOMNodeDisabled_imported_element: + todo_wine ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + if (dom_node) IXMLDOMNode_Release(dom_node); + break; + default: + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + break; + } + + dom_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_previousSibling(locked_node, &dom_node); + ok(dom_node != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, dom_node); + switch (node_kind) { + case DOMNodeDisabled_element: + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + IXMLDOMNode_Release(dom_node); + break; + default: + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + break; + } + + dom_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_nextSibling(locked_node, &dom_node); + ok(dom_node != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, dom_node); + switch (node_kind) { + case DOMNodeDisabled_element: + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + IXMLDOMNode_Release(dom_node); + break; + default: + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + break; + } + + attributes = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_attributes(locked_node, &attributes); + ok(attributes != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, attributes); + switch (node_kind) { + case DOMNodeDisabled_element: + case DOMNodeDisabled_imported_element: + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + IXMLDOMNamedNodeMap_Release(attributes); + break; + default: + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + break; + } + + /* insertBefore and appendChild tests are positioned after the + tests that look for child nodes because Wine currently creates + the nodes */ + + /* only domdocument and element have child nodes to attempt to + replace or remove */ + if (node_kind == DOMNodeDisabled_domdoc || + node_kind == DOMNodeDisabled_element || + node_kind == DOMNodeDisabled_imported_element) { + dom_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_firstChild(locked_node, &dom_node); + todo_wine ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(dom_node != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, dom_node); + /* dom_node used by next tests */ + + text = (void*)0xdeadbeef; + out_node = (void*)0xdeadbeef; + hr = IXMLDOMDocument_createTextNode(locked_doc, _bstr_("Some Element"), &text); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(text != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, text); + hr = IXMLDOMNode_replaceChild(locked_node, (IXMLDOMNode*)text, dom_node, &out_node); + todo_wine ok(hr == E_FAIL, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(out_node == (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, out_node); + IXMLDOMText_Release(text); + if (out_node && out_node != (void*)0xdeadbeef) IXMLDOMNode_Release(out_node); + + out_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_removeChild(locked_node, dom_node, &out_node); + todo_wine ok(hr == E_FAIL, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(out_node == (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, out_node); + if (out_node && out_node != (void*)0xdeadbeef) IXMLDOMNode_Release(out_node); + + if (dom_node) IXMLDOMNode_Release(dom_node); + } + + variant_bool = VARIANT_FALSE; + hr = IXMLDOMNode_hasChildNodes(locked_node, &variant_bool); + switch (node_kind) { + case DOMNodeDisabled_domdoc: + case DOMNodeDisabled_element: + case DOMNodeDisabled_imported_element: + todo_wine ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + todo_wine ok(variant_bool == VARIANT_TRUE, "DOMNodeDisabledTest(%d): Got %d.\n", node_kind, variant_bool); + break; + default: + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + break; + } + + text = (void*)0xdeadbeef; + out_node = (void*)0xdeadbeef; + hr = IXMLDOMDocument_createTextNode(locked_doc, _bstr_("Some Element"), &text); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(text != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, text); + V_VT(&variant) = VT_NULL; + hr = IXMLDOMNode_insertBefore(locked_node, (IXMLDOMNode*)text, variant, &out_node); + todo_wine_if( + node_kind == DOMNodeDisabled_domdoc || + node_kind == DOMNodeDisabled_domdoc_fragment || + node_kind == DOMNodeDisabled_element || + node_kind == DOMNodeDisabled_text || + node_kind == DOMNodeDisabled_created_text || + node_kind == DOMNodeDisabled_created_comment || + node_kind == DOMNodeDisabled_imported_element || + node_kind == DOMNodeDisabled_imported_text + ) ok(hr == E_FAIL, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + todo_wine ok(out_node == (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, out_node); + IXMLDOMText_Release(text); + if (out_node && out_node != (void*)0xdeadbeef) IXMLDOMNode_Release(out_node); + + text = (void*)0xdeadbeef; + out_node = (void*)0xdeadbeef; + hr = IXMLDOMDocument_createTextNode(locked_doc, _bstr_("Some Element"), &text); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(text != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, text); + V_VT(&variant) = VT_NULL; + hr = IXMLDOMNode_appendChild(locked_node, (IXMLDOMNode*)text, &out_node); + todo_wine_if( + node_kind == DOMNodeDisabled_domdoc || + node_kind == DOMNodeDisabled_domdoc_fragment || + node_kind == DOMNodeDisabled_element || + node_kind == DOMNodeDisabled_text || + node_kind == DOMNodeDisabled_created_text || + node_kind == DOMNodeDisabled_created_comment || + node_kind == DOMNodeDisabled_imported_element || + node_kind == DOMNodeDisabled_imported_text + ) ok(hr == E_FAIL, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + todo_wine ok(out_node == (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, out_node); + IXMLDOMText_Release(text); + if (out_node && out_node != (void*)0xdeadbeef) IXMLDOMNode_Release(out_node); + + document = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_ownerDocument(locked_node, &document); + ok(document != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, document); + switch (node_kind) { + case DOMNodeDisabled_domdoc: + todo_wine ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + if (document) IXMLDOMDocument_Release(document); + break; + default: + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + IXMLDOMDocument_Release(document); + break; + } + + dom_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_cloneNode(locked_node, VARIANT_FALSE, &dom_node); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(dom_node != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, dom_node); + IXMLDOMNode_Release(dom_node); + + dom_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_cloneNode(locked_node, VARIANT_TRUE, &dom_node); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(dom_node != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, dom_node); + IXMLDOMNode_Release(dom_node); + + bstr = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_nodeTypeString(locked_node, &bstr); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(bstr != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, bstr); + switch (node_kind) { + case DOMNodeDisabled_domdoc: + ok(!lstrcmpW(bstr, L"document"), "Incorrect node type\n"); + break; + case DOMNodeDisabled_domdoc_fragment: + ok(!lstrcmpW(bstr, L"documentfragment"), "Incorrect node type\n"); + break; + case DOMNodeDisabled_element: + case DOMNodeDisabled_imported_element: + ok(!lstrcmpW(bstr, L"element"), "Incorrect node type\n"); + break; + case DOMNodeDisabled_created_comment: + ok(!lstrcmpW(bstr, L"comment"), "Incorrect node type\n"); + break; + case DOMNodeDisabled_created_cdata_section: + ok(!lstrcmpW(bstr, L"cdatasection"), "Incorrect node type\n"); + break; + default: + ok(!lstrcmpW(bstr, L"text"), "Incorrect node type\n"); + break; + } + SysFreeString(bstr); + + bstr = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_text(locked_node, &bstr); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(bstr != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, bstr); + SysFreeString(bstr); + + bstr = SysAllocStringLen(L"4321", 4); + hr = IXMLDOMNode_put_text(locked_node, bstr); + todo_wine_if( + node_kind == DOMNodeDisabled_domdoc_fragment || + node_kind == DOMNodeDisabled_element || + node_kind == DOMNodeDisabled_text || + node_kind == DOMNodeDisabled_created_text || + node_kind == DOMNodeDisabled_created_comment || + node_kind == DOMNodeDisabled_created_cdata_section || + node_kind == DOMNodeDisabled_imported_element || + node_kind == DOMNodeDisabled_imported_text + ) ok(hr == E_FAIL, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + SysFreeString(bstr); + + variant_bool = VARIANT_FALSE; + hr = IXMLDOMNode_get_specified(locked_node, &variant_bool); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(variant_bool == VARIANT_TRUE, "DOMNodeDisabledTest(%d): Got %d, expected %d\n", node_kind, variant_bool, VARIANT_TRUE); + + dom_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_definition(locked_node, &dom_node); + todo_wine ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + todo_wine ok(dom_node != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, dom_node); + if (dom_node && dom_node != (void*)0xdeadbeef) IXMLDOMNode_Release(dom_node); + + V_VT(&variant) = VT_NULL; + hr = IXMLDOMNode_get_nodeTypedValue(locked_node, &variant); + switch (node_kind) { + case DOMNodeDisabled_domdoc: + case DOMNodeDisabled_domdoc_fragment: + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + break; + default: + todo_wine_if( + node_kind == DOMNodeDisabled_text || + node_kind == DOMNodeDisabled_created_text || + node_kind == DOMNodeDisabled_imported_text + ) ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + todo_wine_if( + node_kind == DOMNodeDisabled_text || + node_kind == DOMNodeDisabled_created_text || + node_kind == DOMNodeDisabled_imported_text + ) ok(V_VT(&variant) == VT_BSTR, "DOMNodeDisabledTest(%d): Got %d, expected %d\n", node_kind, V_VT(&variant), VT_BSTR); + SysFreeString(V_BSTR(&variant)); + break; + } + + V_VT(&variant) = VT_BSTR; + V_BSTR(&variant) = _bstr_("1"); + hr = IXMLDOMNode_put_nodeTypedValue(locked_node, variant); + todo_wine ok(hr == E_FAIL, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + + hr = IXMLDOMNode_get_dataType(locked_node, &variant); + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + + bstr = _bstr_("char"); + hr = IXMLDOMNode_put_dataType(locked_node, bstr); + todo_wine_if( + node_kind == DOMNodeDisabled_text || + node_kind == DOMNodeDisabled_created_text || + node_kind == DOMNodeDisabled_imported_text + ) ok(hr == E_FAIL, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + + bstr = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_xml(locked_node, &bstr); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(bstr != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, bstr); + SysFreeString(bstr); + + bstr = (void*)0xdeadbeef; + hr = IXMLDOMNode_transformNode(locked_node, (IXMLDOMNode*)stylesheet, &bstr); + todo_wine ok(hr == E_PENDING, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(bstr != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, bstr); + if (bstr) SysFreeString(bstr); + + node_list = (void*)0xdeadbeef; + hr = IXMLDOMNode_selectNodes(locked_node, _bstr_("."), &node_list); + todo_wine ok(hr == E_PENDING, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + todo_wine ok(node_list == (IXMLDOMNodeList*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, node_list); + if (node_list && node_list != (void*)0xdeadbeef) IXMLDOMNodeList_Release(node_list); + + dom_node = (void*)0xdeadbeef; + hr = IXMLDOMNode_selectSingleNode(locked_node, _bstr_("."), &dom_node); + todo_wine ok(hr == E_PENDING, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(dom_node != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, dom_node); + if (dom_node) IXMLDOMNode_Release(dom_node); + + if (node_kind == DOMNodeDisabled_domdoc) { + variant_bool = VARIANT_TRUE; + hr = IXMLDOMNode_get_parsed(locked_node, &variant_bool); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + todo_wine ok(variant_bool == VARIANT_FALSE, "DOMNodeDisabledTest(%d): Got %d, expected %d.\n", node_kind, variant_bool, VARIANT_FALSE); + } else { + variant_bool = VARIANT_FALSE; + hr = IXMLDOMNode_get_parsed(locked_node, &variant_bool); + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(variant_bool == VARIANT_TRUE, "DOMNodeDisabledTest(%d): Got %d, expected %d.\n", node_kind, variant_bool, VARIANT_TRUE); + } + + bstr = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_namespaceURI(locked_node, &bstr); + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(bstr != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, bstr); + SysFreeString(bstr); + + bstr = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_prefix(locked_node, &bstr); + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(bstr != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, bstr); + SysFreeString(bstr); + + bstr = (void*)0xdeadbeef; + hr = IXMLDOMNode_get_baseName(locked_node, &bstr); + ok(bstr != (void*)0xdeadbeef, "DOMNodeDisabledTest(%d): Got %p.\n", node_kind, bstr); + switch (node_kind) { + case DOMNodeDisabled_element: + case DOMNodeDisabled_imported_element: + ok(hr == S_OK, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + ok(!lstrcmpW(bstr, L"BankAccount"), "DOMNodeDisabledTest(%d): Incorrect baseName\n", node_kind); + break; + default: + ok(hr == S_FALSE, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + break; + } + SysFreeString(bstr); + + hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void **)&document); + ok(hr == S_OK, "Failed to create a stylesheet, hr %#x.\n", hr); + V_VT(&variant) = VT_DISPATCH; + V_DISPATCH(&variant) = (IDispatch*)document; + hr = IXMLDOMNode_transformNodeToObject(locked_node, (IXMLDOMNode*)stylesheet, variant); + todo_wine ok(hr == E_PENDING, "DOMNodeDisabledTest(%d): Unexpected hr %#x.\n", node_kind, hr); + IXMLDOMDocument_Release(document); + + IXMLDOMDocument_Release(stylesheet); +} + +static void test_mxwriter_domdoc_startDocument_disables_domdoc_methods(void) +{ + HRESULT hr; + VARIANT dest; + IMXWriter *writer; + ISAXContentHandler *content; + IXMLDOMDocument *domdoc; + /* for disabled node methods */ + VARIANT_BOOL deep_clone; + IXMLDOMNode *temp_node = NULL; + IXMLDOMNodeList *temp_node_list = NULL; + IXMLDOMNode *element_node = NULL, + *text_node = NULL, + *import_text_node = NULL, + *import_element_node = NULL; + IXMLDOMDocumentFragment *document_fragment = NULL; + IXMLDOMText *text = NULL; + IXMLDOMComment *comment = NULL; + IXMLDOMCDATASection *cdata_section = NULL; + IXMLDOMDocument2 *domdoc2; + IXMLDOMDocument3 *domdoc3; + + /* Create mxwriter and domdoc, set domdoc output, start document, add elements */ + hr = CoCreateInstance(&CLSID_MXXMLWriter60, NULL, CLSCTX_INPROC_SERVER, &IID_IMXWriter, (void**)&writer); + ok(hr == S_OK, "Failed to create a writer, hr %#x.\n", hr); + + hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void **)&domdoc); + ok(hr == S_OK, "Failed to create a document, hr %#x.\n", hr); + hr = IXMLDOMDocument_QueryInterface(domdoc, &IID_IXMLDOMDocument2, (void**)&domdoc2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + hr = IXMLDOMDocument_QueryInterface(domdoc, &IID_IXMLDOMDocument2, (void**)&domdoc3); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + V_VT(&dest) = VT_DISPATCH; + V_DISPATCH(&dest) = (IDispatch *)domdoc; + + hr = IMXWriter_put_output(writer, dest); + todo_wine ok(hr == S_OK, "Failed to set writer output, hr %#x.\n", hr); + + hr = ISAXContentHandler_startDocument(content); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"Accounts", 8, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"BankAccount", 11, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"BankAccount", 11); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"BankAccount", 11, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = ISAXContentHandler_characters(content, L"12345", 5); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"BankAccount", 11); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"BankAccount", 11, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"BankAccount", 11); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + + /* Access created nodes. */ + temp_node = NULL; + hr = IXMLDOMDocument_get_firstChild(domdoc, &temp_node); + todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + temp_node_list = NULL; + if (temp_node) { + hr = IXMLDOMNode_get_childNodes(temp_node, &temp_node_list); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + } + + element_node = NULL; + if (temp_node_list) { + hr = IXMLDOMNodeList_get_item(temp_node_list, 1, &element_node); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + } + + if (element_node) { + hr = IXMLDOMNode_get_firstChild(element_node, &text_node); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + } + + deep_clone = VARIANT_TRUE; + hr = IXMLDOMDocument3_importNode(domdoc3, text_node, deep_clone, &import_text_node); + todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IXMLDOMDocument3_importNode(domdoc3, element_node, deep_clone, &import_element_node); + todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + if (temp_node) IXMLDOMNode_Release(temp_node); + if (temp_node_list) IXMLDOMNodeList_Release(temp_node_list); + + + /* + Call IXMLDOMNode methods on various nodes that can be reached + from the document. + */ + check_domnode_methods_disabled(domdoc, (IXMLDOMNode*)domdoc, DOMNodeDisabled_domdoc); + + hr = IXMLDOMDocument_createDocumentFragment(domdoc, &document_fragment); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + check_domnode_methods_disabled(domdoc, (IXMLDOMNode*)document_fragment, DOMNodeDisabled_domdoc_fragment); + IXMLDOMDocumentFragment_Release(document_fragment); + + if (element_node) check_domnode_methods_disabled(domdoc, element_node, DOMNodeDisabled_element); + if (text_node) check_domnode_methods_disabled(domdoc, text_node, DOMNodeDisabled_text); + + hr = IXMLDOMDocument_createTextNode(domdoc, _bstr_("some text"), &text); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + check_domnode_methods_disabled(domdoc, (IXMLDOMNode*)text, DOMNodeDisabled_created_text); + IXMLDOMText_Release(text); + + hr = IXMLDOMDocument_createComment(domdoc, _bstr_("some comment"), &comment); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + check_domnode_methods_disabled(domdoc, (IXMLDOMNode*)comment, DOMNodeDisabled_created_comment); + IXMLDOMComment_Release(comment); + + hr = IXMLDOMDocument_createCDATASection(domdoc, _bstr_("some CDATA"), &cdata_section); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + check_domnode_methods_disabled(domdoc, (IXMLDOMNode*)cdata_section, DOMNodeDisabled_created_cdata_section); + IXMLDOMCDATASection_Release(cdata_section); + + if (import_element_node) check_domnode_methods_disabled(domdoc, import_element_node, DOMNodeDisabled_imported_element); + if (import_text_node) check_domnode_methods_disabled(domdoc, import_text_node, DOMNodeDisabled_imported_text); + + + 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); + IXMLDOMDocument3_Release(domdoc3); + IXMLDOMDocument2_Release(domdoc2); + IXMLDOMDocument_Release(domdoc); + ISAXContentHandler_Release(content); + IMXWriter_Release(writer); + free_bstrs(); +} static void test_mxwriter_domdoc(void) { ISAXContentHandler *content; @@ -6040,6 +6658,7 @@ START_TEST(saxreader) test_mxwriter_properties(); test_mxwriter_flush(); test_mxwriter_stream(); + test_mxwriter_domdoc_startDocument_disables_domdoc_methods(); test_mxwriter_domdoc(); test_mxwriter_encoding(); test_mxwriter_dispex(); -- 2.26.2