Based on patch from Damjan Jovanovic damjan.jov@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=53531
-- v3: msxml3: Handle default namespace in get_namespaceURI. msxml3: Handle default namespace in get_prefix. msxml3: Handle default namespace in get_nodeName. msxml3: Handle default namespace in get_baseName. msxml3: Handle null prefix in get_item. msxml6/tests: Add tests for default namespace. msxml4/tests: Add tests for default namespace. msxml3/tests: Add tests for default namespace. msxml6/tests: Copy create namespace tests. msxml4/tests: Copy create namespace tests. msxml6/tests: Copy namespaces as attributes tests. msxml4/tests: Copy namespaces as attributes tests. msmxl3/tests: Add tests for get_xml. msxml3/tests: Remove msxml6 tests. msxml3/tests: Fix failure messages.
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/tests/domdoc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index cf9fb62a65e..6590a8dbad4 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13765,12 +13765,12 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_prefix(item, &str); if (test->prefixes[i]) { - ok(hr == S_OK, "Failed to get node name, hr %#lx.\n", hr); + ok(hr == S_OK, "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str); } else - ok(hr == S_FALSE, "Failed to get node name, hr %#lx.\n", hr); + ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr );
str = NULL; hr = IXMLDOMNode_get_baseName(item, &str); @@ -13782,7 +13782,7 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { - ok(hr == S_OK, "Failed to get node name, hr %#lx.\n", hr); + ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, _bstr_(entry->xmlns_uri)), "got %s\n", wine_dbgstr_w(str)); else @@ -13790,7 +13790,7 @@ static void test_namespaces_as_attributes(void) SysFreeString(str); } else - ok(hr == S_FALSE, "Failed to get node name, hr %#lx.\n", hr); + ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr );
str = NULL; hr = IXMLDOMNode_get_text(item, &str);
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/tests/domdoc.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 6590a8dbad4..bbe8be2a069 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13648,19 +13648,17 @@ todo_wine { typedef struct _namespace_as_attribute_t { const GUID *guid; const char *clsid; - const char *xmlns_uri; } namespace_as_attribute_t;
static const namespace_as_attribute_t namespace_as_attribute_test_data[] = { - { &CLSID_DOMDocument, "CLSID_DOMDocument", "" }, - { &CLSID_DOMDocument2, "CLSID_DOMDocument2", "" }, - { &CLSID_DOMDocument26, "CLSID_DOMDocument26", "" }, - { &CLSID_DOMDocument30, "CLSID_DOMDocument30", "" }, - { &CLSID_DOMDocument40, "CLSID_DOMDocument40", "" }, - { &CLSID_DOMDocument60, "CLSID_DOMDocument60", "http://www.w3.org/2000/xmlns/" }, + { &CLSID_DOMDocument, "CLSID_DOMDocument" }, + { &CLSID_DOMDocument2, "CLSID_DOMDocument2" }, + { &CLSID_DOMDocument26, "CLSID_DOMDocument26" }, + { &CLSID_DOMDocument30, "CLSID_DOMDocument30" }, { 0 } };
+/* see dlls/msxml[46]/tests/domdoc.c */ static void test_namespaces_as_attributes(void) { const namespace_as_attribute_t *entry = namespace_as_attribute_test_data; @@ -13784,7 +13782,7 @@ static void test_namespaces_as_attributes(void) { ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) - ok(!lstrcmpW(str, _bstr_(entry->xmlns_uri)), "got %s\n", wine_dbgstr_w(str)); + ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/tests/domdoc.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index bbe8be2a069..28aa8965ba5 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13670,6 +13670,7 @@ static void test_namespaces_as_attributes(void) const char *basenames[3]; const char *uris[3]; const char *texts[3]; + const char *xmls[3]; }; static const struct test tests[] = { { @@ -13679,24 +13680,27 @@ static void test_namespaces_as_attributes(void) { "b", "d", "ns" }, /* baseName */ { "nshref", NULL, "" }, /* namespaceURI */ { "b attr", "d attr", "nshref" }, /* text */ + { "ns:b="b attr"", "d="d attr"", "xmlns:ns="nshref"" }, /* xml */ }, /* property only */ { "<a d="d attr" />", 1, - { "d" }, /* nodeName */ - { NULL }, /* prefix */ - { "d" }, /* baseName */ - { NULL }, /* namespaceURI */ - { "d attr" }, /* text */ + { "d" }, /* nodeName */ + { NULL }, /* prefix */ + { "d" }, /* baseName */ + { NULL }, /* namespaceURI */ + { "d attr" }, /* text */ + { "d="d attr"" }, /* xml */ }, /* namespace only */ { "<a xmlns:ns="nshref" />", 1, - { "xmlns:ns" }, /* nodeName */ - { "xmlns" }, /* prefix */ - { "ns" }, /* baseName */ - { "" }, /* namespaceURI */ - { "nshref" }, /* text */ + { "xmlns:ns" }, /* nodeName */ + { "xmlns" }, /* prefix */ + { "ns" }, /* baseName */ + { "" }, /* namespaceURI */ + { "nshref" }, /* text */ + { "xmlns:ns="nshref"" }, /* xml */ }, /* no properties or namespaces */ { @@ -13796,6 +13800,12 @@ static void test_namespaces_as_attributes(void) ok(!lstrcmpW(str, _bstr_(test->texts[i])), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
+ str = NULL; + hr = IXMLDOMNode_get_xml(item, &str); + ok(SUCCEEDED(hr), "Failed to get node xml, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->xmls[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + IXMLDOMNode_Release(item); }
From: Daniel Lehman dlehman25@gmail.com
--- configure.ac | 1 + dlls/msxml4/tests/Makefile.in | 5 + dlls/msxml4/tests/domdoc.c | 235 ++++++++++++++++++++++++++++++++++ 3 files changed, 241 insertions(+) create mode 100644 dlls/msxml4/tests/Makefile.in create mode 100644 dlls/msxml4/tests/domdoc.c
diff --git a/configure.ac b/configure.ac index 0a6171e7fd3..f73926da68a 100644 --- a/configure.ac +++ b/configure.ac @@ -2844,6 +2844,7 @@ WINE_CONFIG_MAKEFILE(dlls/msxml2) WINE_CONFIG_MAKEFILE(dlls/msxml3) WINE_CONFIG_MAKEFILE(dlls/msxml3/tests) WINE_CONFIG_MAKEFILE(dlls/msxml4) +WINE_CONFIG_MAKEFILE(dlls/msxml4/tests) WINE_CONFIG_MAKEFILE(dlls/msxml6) WINE_CONFIG_MAKEFILE(dlls/mtxdm) WINE_CONFIG_MAKEFILE(dlls/ncrypt) diff --git a/dlls/msxml4/tests/Makefile.in b/dlls/msxml4/tests/Makefile.in new file mode 100644 index 00000000000..6515c06f112 --- /dev/null +++ b/dlls/msxml4/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = msxml4.dll +IMPORTS = oleaut32 ole32 + +C_SRCS = \ + domdoc.c diff --git a/dlls/msxml4/tests/domdoc.c b/dlls/msxml4/tests/domdoc.c new file mode 100644 index 00000000000..742c437152c --- /dev/null +++ b/dlls/msxml4/tests/domdoc.c @@ -0,0 +1,235 @@ +/* + * XML test + * + * Copyright 2005 Mike McCormack for CodeWeavers + * Copyright 2007-2008 Alistair Leslie-Hughes + * Copyright 2010-2011 Adam Martinson for CodeWeavers + * Copyright 2010-2013 Nikolay Sivov for CodeWeavers + * Copyright 2023 Daniel Lehman + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +#define COBJMACROS +#define CONST_VTABLE + +#include <stdio.h> +#include <assert.h> + +#include "windows.h" + +#include "initguid.h" +#include "msxml2.h" + +#include "wine/test.h" + +static BSTR alloced_bstrs[256]; +static int alloced_bstrs_count; + +static BSTR alloc_str_from_narrow(const char *str) +{ + int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */ + MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); + return ret; +} + +static BSTR _bstr_(const char *str) +{ + assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs)); + alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str); + return alloced_bstrs[alloced_bstrs_count++]; +} + +static void free_bstrs(void) +{ + int i; + for (i = 0; i < alloced_bstrs_count; i++) + SysFreeString(alloced_bstrs[i]); + alloced_bstrs_count = 0; +} + +/* see dlls/msxml[36]/tests/domdoc.c */ +static void test_namespaces_as_attributes(void) +{ + struct test { + const char *xml; + int explen; + const char *names[3]; + const char *prefixes[3]; + const char *basenames[3]; + const char *uris[3]; + const char *texts[3]; + const char *xmls[3]; + }; + static const struct test tests[] = { + { + "<a ns:b="b attr" d="d attr" xmlns:ns="nshref" />", 3, + { "ns:b", "d", "xmlns:ns" }, /* nodeName */ + { "ns", NULL, "xmlns" }, /* prefix */ + { "b", "d", "ns" }, /* baseName */ + { "nshref", NULL, "" }, /* namespaceURI */ + { "b attr", "d attr", "nshref" }, /* text */ + { "ns:b="b attr"", "d="d attr"", "xmlns:ns="nshref"" }, /* xml */ + }, + /* property only */ + { + "<a d="d attr" />", 1, + { "d" }, /* nodeName */ + { NULL }, /* prefix */ + { "d" }, /* baseName */ + { NULL }, /* namespaceURI */ + { "d attr" }, /* text */ + { "d="d attr"" }, /* xml */ + }, + /* namespace only */ + { + "<a xmlns:ns="nshref" />", 1, + { "xmlns:ns" }, /* nodeName */ + { "xmlns" }, /* prefix */ + { "ns" }, /* baseName */ + { "" }, /* namespaceURI */ + { "nshref" }, /* text */ + { "xmlns:ns="nshref"" }, /* xml */ + }, + /* no properties or namespaces */ + { + "<a />", 0, + }, + + { NULL } + }; + const struct test *test; + IXMLDOMNamedNodeMap *map; + IXMLDOMNode *node, *item; + IXMLDOMDocument2 *doc; + VARIANT_BOOL b; + LONG len, i; + HRESULT hr; + BSTR str; + + test = tests; + while (test->xml) { + hr = CoCreateInstance(&CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc); + ok(SUCCEEDED(hr), "Failed to create DOMDocument40, hr %#lx.\n", hr); + + hr = IXMLDOMDocument2_loadXML(doc, _bstr_(test->xml), &b); + ok(hr == S_OK, "Failed to load xml, hr %#lx.\n", hr); + + node = NULL; + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("a"), &node); + ok(SUCCEEDED(hr), "Failed to select a node, hr %#lx.\n", hr); + + hr = IXMLDOMNode_get_attributes(node, &map); + ok(SUCCEEDED(hr), "Failed to get attributes, hr %#lx.\n", hr); + + len = -1; + hr = IXMLDOMNamedNodeMap_get_length(map, &len); + ok(SUCCEEDED(hr), "Failed to get map length, hr %#lx.\n", hr); + ok(len == test->explen, "got %ld\n", len); + + item = NULL; + hr = IXMLDOMNamedNodeMap_get_item(map, test->explen+1, &item); + ok(hr == S_FALSE, "Failed to get item, hr %#lx.\n", hr); + ok(!item, "Item should be NULL\n"); + + for (i = 0; i < len; i++) + { + item = NULL; + hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); + ok(SUCCEEDED(hr), "Failed to get item, hr %#lx.\n", hr); + + str = NULL; + hr = IXMLDOMNode_get_nodeName(item, &str); + ok(SUCCEEDED(hr), "Failed to get node name, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->names[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + str = NULL; + hr = IXMLDOMNode_get_prefix(item, &str); + if (test->prefixes[i]) + { + ok(hr == S_OK, "Failed to get prefix, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + } + else + ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr ); + + str = NULL; + hr = IXMLDOMNode_get_baseName(item, &str); + ok(SUCCEEDED(hr), "Failed to get base name, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->basenames[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + str = NULL; + hr = IXMLDOMNode_get_namespaceURI(item, &str); + if (test->uris[i]) + { + ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); + if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) + ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str)); + else + ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + } + else + ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr ); + + str = NULL; + hr = IXMLDOMNode_get_text(item, &str); + ok(SUCCEEDED(hr), "Failed to get node text, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->texts[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + str = NULL; + hr = IXMLDOMNode_get_xml(item, &str); + ok(SUCCEEDED(hr), "Failed to get node xml, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->xmls[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + IXMLDOMNode_Release(item); + } + + IXMLDOMNamedNodeMap_Release(map); + IXMLDOMNode_Release(node); + IXMLDOMDocument2_Release(doc); + + test++; + } + free_bstrs(); +} + +START_TEST(domdoc) +{ + HRESULT hr; + IXMLDOMDocument2 *doc; + + hr = CoInitialize( NULL ); + ok( hr == S_OK, "failed to init com\n"); + if (hr != S_OK) return; + + hr = CoCreateInstance(&CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc); + if (hr != S_OK) + { + win_skip("class &CLSID_DOMDocument40 not supported\n"); + return; + } + + test_namespaces_as_attributes(); + + CoUninitialize(); +}
From: Daniel Lehman dlehman25@gmail.com
--- configure.ac | 1 + dlls/msxml6/tests/Makefile.in | 5 + dlls/msxml6/tests/domdoc.c | 228 ++++++++++++++++++++++++++++++++++ 3 files changed, 234 insertions(+) create mode 100644 dlls/msxml6/tests/Makefile.in create mode 100644 dlls/msxml6/tests/domdoc.c
diff --git a/configure.ac b/configure.ac index f73926da68a..48ccc05e74a 100644 --- a/configure.ac +++ b/configure.ac @@ -2846,6 +2846,7 @@ WINE_CONFIG_MAKEFILE(dlls/msxml3/tests) WINE_CONFIG_MAKEFILE(dlls/msxml4) WINE_CONFIG_MAKEFILE(dlls/msxml4/tests) WINE_CONFIG_MAKEFILE(dlls/msxml6) +WINE_CONFIG_MAKEFILE(dlls/msxml6/tests) WINE_CONFIG_MAKEFILE(dlls/mtxdm) WINE_CONFIG_MAKEFILE(dlls/ncrypt) WINE_CONFIG_MAKEFILE(dlls/ncrypt/tests) diff --git a/dlls/msxml6/tests/Makefile.in b/dlls/msxml6/tests/Makefile.in new file mode 100644 index 00000000000..47231ace2ee --- /dev/null +++ b/dlls/msxml6/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = msxml6.dll +IMPORTS = oleaut32 ole32 + +C_SRCS = \ + domdoc.c diff --git a/dlls/msxml6/tests/domdoc.c b/dlls/msxml6/tests/domdoc.c new file mode 100644 index 00000000000..a943d58b835 --- /dev/null +++ b/dlls/msxml6/tests/domdoc.c @@ -0,0 +1,228 @@ +/* + * XML test + * + * Copyright 2005 Mike McCormack for CodeWeavers + * Copyright 2007-2008 Alistair Leslie-Hughes + * Copyright 2010-2011 Adam Martinson for CodeWeavers + * Copyright 2010-2013 Nikolay Sivov for CodeWeavers + * Copyright 2023 Daniel Lehman + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +#define COBJMACROS +#define CONST_VTABLE + +#include <stdio.h> +#include <assert.h> + +#include "windows.h" + +#include "initguid.h" +#include "msxml6.h" + +#include "wine/test.h" + +static BSTR alloced_bstrs[256]; +static int alloced_bstrs_count; + +static BSTR alloc_str_from_narrow(const char *str) +{ + int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */ + MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); + return ret; +} + +static BSTR _bstr_(const char *str) +{ + assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs)); + alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str); + return alloced_bstrs[alloced_bstrs_count++]; +} + +static void free_bstrs(void) +{ + int i; + for (i = 0; i < alloced_bstrs_count; i++) + SysFreeString(alloced_bstrs[i]); + alloced_bstrs_count = 0; +} + +/* see dlls/msxml[34]/tests/domdoc.c */ +static void test_namespaces_as_attributes(void) +{ + struct test { + const char *xml; + int explen; + const char *names[3]; + const char *prefixes[3]; + const char *basenames[3]; + const char *uris[3]; + const char *texts[3]; + const char *xmls[3]; + }; + static const struct test tests[] = { + { + "<a ns:b="b attr" d="d attr" xmlns:ns="nshref" />", 3, + { "ns:b", "d", "xmlns:ns" }, /* nodeName */ + { "ns", NULL, "xmlns" }, /* prefix */ + { "b", "d", "ns" }, /* baseName */ + { "nshref", NULL, "" }, /* namespaceURI */ + { "b attr", "d attr", "nshref" }, /* text */ + { "ns:b="b attr"", "d="d attr"", "xmlns:ns="nshref"" }, /* xml */ + }, + /* property only */ + { + "<a d="d attr" />", 1, + { "d" }, /* nodeName */ + { NULL }, /* prefix */ + { "d" }, /* baseName */ + { NULL }, /* namespaceURI */ + { "d attr" }, /* text */ + { "d="d attr"" }, /* xml */ + }, + /* namespace only */ + { + "<a xmlns:ns="nshref" />", 1, + { "xmlns:ns" }, /* nodeName */ + { "xmlns" }, /* prefix */ + { "ns" }, /* baseName */ + { "" }, /* namespaceURI */ + { "nshref" }, /* text */ + { "xmlns:ns="nshref"" }, /* xml */ + }, + /* no properties or namespaces */ + { + "<a />", 0, + }, + + { NULL } + }; + const struct test *test; + IXMLDOMNamedNodeMap *map; + IXMLDOMNode *node, *item; + IXMLDOMDocument2 *doc; + VARIANT_BOOL b; + LONG len, i; + HRESULT hr; + BSTR str; + + test = tests; + while (test->xml) { + hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc); + ok(SUCCEEDED(hr), "Failed to create DOMDocument60, hr %#lx.\n", hr); + + hr = IXMLDOMDocument2_loadXML(doc, _bstr_(test->xml), &b); + ok(hr == S_OK, "Failed to load xml, hr %#lx.\n", hr); + + node = NULL; + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("a"), &node); + ok(SUCCEEDED(hr), "Failed to select a node, hr %#lx.\n", hr); + + hr = IXMLDOMNode_get_attributes(node, &map); + ok(SUCCEEDED(hr), "Failed to get attributes, hr %#lx.\n", hr); + + len = -1; + hr = IXMLDOMNamedNodeMap_get_length(map, &len); + ok(SUCCEEDED(hr), "Failed to get map length, hr %#lx.\n", hr); + ok(len == test->explen, "got %ld\n", len); + + item = NULL; + hr = IXMLDOMNamedNodeMap_get_item(map, test->explen+1, &item); + ok(hr == S_FALSE, "Failed to get item, hr %#lx.\n", hr); + ok(!item, "Item should be NULL\n"); + + for (i = 0; i < len; i++) + { + item = NULL; + hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); + ok(SUCCEEDED(hr), "Failed to get item, hr %#lx.\n", hr); + + str = NULL; + hr = IXMLDOMNode_get_nodeName(item, &str); + ok(SUCCEEDED(hr), "Failed to get node name, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->names[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + str = NULL; + hr = IXMLDOMNode_get_prefix(item, &str); + if (test->prefixes[i]) + { + ok(hr == S_OK, "Failed to get prefix, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + } + else + ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr ); + + str = NULL; + hr = IXMLDOMNode_get_baseName(item, &str); + ok(SUCCEEDED(hr), "Failed to get base name, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->basenames[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + str = NULL; + hr = IXMLDOMNode_get_namespaceURI(item, &str); + if (test->uris[i]) + { + ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); + if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) + ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/"), + "got %s\n", wine_dbgstr_w(str)); + else + ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + } + else + ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr ); + + str = NULL; + hr = IXMLDOMNode_get_text(item, &str); + ok(SUCCEEDED(hr), "Failed to get node text, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->texts[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + str = NULL; + hr = IXMLDOMNode_get_xml(item, &str); + ok(SUCCEEDED(hr), "Failed to get node xml, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->xmls[i])), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + IXMLDOMNode_Release(item); + } + + IXMLDOMNamedNodeMap_Release(map); + IXMLDOMNode_Release(node); + IXMLDOMDocument2_Release(doc); + + test++; + } + free_bstrs(); +} + +START_TEST(domdoc) +{ + HRESULT hr; + + hr = CoInitialize( NULL ); + ok( hr == S_OK, "failed to init com\n"); + if (hr != S_OK) return; + + test_namespaces_as_attributes(); + + CoUninitialize(); +}
From: Daniel Lehman dlehman25@gmail.com
with changes for msxml4 --- dlls/msxml4/tests/domdoc.c | 98 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+)
diff --git a/dlls/msxml4/tests/domdoc.c b/dlls/msxml4/tests/domdoc.c index 742c437152c..66b4610fe0e 100644 --- a/dlls/msxml4/tests/domdoc.c +++ b/dlls/msxml4/tests/domdoc.c @@ -62,6 +62,103 @@ static void free_bstrs(void) alloced_bstrs_count = 0; }
+struct attrtest_t { + const char *name; + const char *uri; + const char *prefix; + const char *href; +}; + +static struct attrtest_t attrtests[] = { + { "xmlns", "http://www.w3.org/2000/xmlns/", "xmlns", "xmlns" }, + { "xmlns", "nondefaulturi", "xmlns", "xmlns" }, + { "c", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/" }, + { "c", "nsref1", NULL, "nsref1" }, + { "ns:c", "nsref1", "ns", "nsref1" }, + { "xmlns:c", "http://www.w3.org/2000/xmlns/", "xmlns", "" }, + { "xmlns:c", "nondefaulturi", "xmlns", "" }, + { 0 } +}; + +/* see dlls/msxml[36]/tests/domdoc.c */ +static void test_create_attribute(void) +{ + struct attrtest_t *ptr = attrtests; + IXMLDOMElement *el; + IXMLDOMDocument2 *doc; + IXMLDOMNode *node, *node2; + VARIANT var; + HRESULT hr; + int i = 0; + BSTR str; + + hr = CoCreateInstance(&CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc); + ok(SUCCEEDED(hr), "Failed to create DOMDocument40, hr %#lx.\n", hr); + + while (ptr->name) + { + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(ptr->name), _bstr_(ptr->uri), &node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + str = NULL; + hr = IXMLDOMNode_get_prefix(node, &str); + if (ptr->prefix) + { + /* MSXML4 can report different results with different service packs */ + ok(hr == S_OK || broken(hr == S_FALSE), "Failed to get prefix, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(ptr->prefix)) || broken(!str), "got %s\n", wine_dbgstr_w(str)); + } + else + { + ok(hr == S_FALSE, "%d: unexpected hr %#lx\n", i, hr); + ok(str == NULL, "%d: got prefix %s\n", i, wine_dbgstr_w(str)); + } + SysFreeString(str); + + str = NULL; + hr = IXMLDOMNode_get_namespaceURI(node, &str); + ok(hr == S_OK, "%d: unexpected hr %#lx\n", i, hr); + ok(!lstrcmpW(str, _bstr_(ptr->href)), "%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), ptr->href); + SysFreeString(str); + + IXMLDOMNode_Release(node); + free_bstrs(); + + i++; + ptr++; + } + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ELEMENT; + hr = IXMLDOMDocument2_createNode(doc, var, _bstr_("e"), NULL, &node2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXMLDOMNode_QueryInterface(node2, &IID_IXMLDOMElement, (void**)&el); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IXMLDOMNode_Release(node2); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + hr = IXMLDOMDocument2_createNode(doc, var, _bstr_("xmlns:a"), _bstr_("http://www.w3.org/2000/xmlns/"), &node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXMLDOMElement_setAttributeNode(el, (IXMLDOMAttribute*)node, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + /* for some reason default namespace uri is not reported */ + hr = IXMLDOMNode_get_namespaceURI(node, &str); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(str, L""), "got uri %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + IXMLDOMNode_Release(node); + IXMLDOMElement_Release(el); + IXMLDOMDocument2_Release(doc); + free_bstrs(); +} + /* see dlls/msxml[36]/tests/domdoc.c */ static void test_namespaces_as_attributes(void) { @@ -229,6 +326,7 @@ START_TEST(domdoc) return; }
+ test_create_attribute(); test_namespaces_as_attributes();
CoUninitialize();
From: Daniel Lehman dlehman25@gmail.com
with changes for msxml6 and TODOs for wine --- dlls/msxml6/tests/domdoc.c | 105 +++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+)
diff --git a/dlls/msxml6/tests/domdoc.c b/dlls/msxml6/tests/domdoc.c index a943d58b835..741a4ff7d09 100644 --- a/dlls/msxml6/tests/domdoc.c +++ b/dlls/msxml6/tests/domdoc.c @@ -62,6 +62,110 @@ static void free_bstrs(void) alloced_bstrs_count = 0; }
+struct attrtest_t { + const char *name; + const char *uri; + const char *prefix; + const char *href; + BOOL todo; +}; + +static struct attrtest_t attrtests[] = { + { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/", TRUE }, + { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/", TRUE }, + { "c", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/" }, + { "c", "nsref1", NULL, "nsref1" }, + { "ns:c", "nsref1", "ns", "nsref1" }, + { "xmlns:c", "http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2000/xmlns/" }, + { "xmlns:c", "nondefaulturi", "xmlns", "http://www.w3.org/2000/xmlns/" }, + { 0 } +}; + +/* see dlls/msxml[34]/tests/domdoc.c */ +static void test_create_attribute(void) +{ + struct attrtest_t *ptr = attrtests; + IXMLDOMElement *el; + IXMLDOMDocument2 *doc; + IXMLDOMNode *node, *node2; + VARIANT var; + HRESULT hr; + int i = 0; + BSTR str; + + hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc); + ok(SUCCEEDED(hr), "Failed to create DOMDocument60, hr %#lx.\n", hr); + + while (ptr->name) + { + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(ptr->name), _bstr_(ptr->uri), &node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + str = NULL; + hr = IXMLDOMNode_get_prefix(node, &str); + if (ptr->prefix) + { + ok(hr == S_OK, "%d: unexpected hr %#lx\n", i, hr); + ok(!lstrcmpW(str, _bstr_(ptr->prefix)), "%d: got prefix %s, expected %s\n", i, wine_dbgstr_w(str), ptr->prefix); + } + else + { + todo_wine_if(ptr->todo) { + ok(hr == S_FALSE, "%d: unexpected hr %#lx\n", i, hr); + ok(str == NULL, "%d: got prefix %s\n", i, wine_dbgstr_w(str)); + } + } + SysFreeString(str); + + str = NULL; + hr = IXMLDOMNode_get_namespaceURI(node, &str); + ok(hr == S_OK, "%d: unexpected hr %#lx\n", i, hr); + todo_wine_if(ptr->todo) + ok(!lstrcmpW(str, _bstr_(ptr->href)) || + broken(!ptr->prefix && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */ + "%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), ptr->href); + SysFreeString(str); + + IXMLDOMNode_Release(node); + free_bstrs(); + + i++; + ptr++; + } + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ELEMENT; + hr = IXMLDOMDocument2_createNode(doc, var, _bstr_("e"), NULL, &node2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXMLDOMNode_QueryInterface(node2, &IID_IXMLDOMElement, (void**)&el); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IXMLDOMNode_Release(node2); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + hr = IXMLDOMDocument2_createNode(doc, var, _bstr_("xmlns:a"), _bstr_("http://www.w3.org/2000/xmlns/"), &node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXMLDOMElement_setAttributeNode(el, (IXMLDOMAttribute*)node, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + /* for some reason default namespace uri is not reported */ + hr = IXMLDOMNode_get_namespaceURI(node, &str); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/") || + broken(!ptr->prefix && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */ + "got uri %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + IXMLDOMNode_Release(node); + IXMLDOMElement_Release(el); + IXMLDOMDocument2_Release(doc); + free_bstrs(); +} + /* see dlls/msxml[34]/tests/domdoc.c */ static void test_namespaces_as_attributes(void) { @@ -222,6 +326,7 @@ START_TEST(domdoc) ok( hr == S_OK, "failed to init com\n"); if (hr != S_OK) return;
+ test_create_attribute(); test_namespaces_as_attributes();
CoUninitialize();
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/tests/domdoc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 28aa8965ba5..6b63a7c1c3d 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13671,6 +13671,7 @@ static void test_namespaces_as_attributes(void) const char *uris[3]; const char *texts[3]; const char *xmls[3]; + BOOL todo; }; static const struct test tests[] = { { @@ -13702,6 +13703,17 @@ static void test_namespaces_as_attributes(void) { "nshref" }, /* text */ { "xmlns:ns="nshref"" }, /* xml */ }, + /* default namespace */ + { + "<a xmlns="nshref" />", 1, + { "xmlns" }, /* nodeName */ + { "xmlns" }, /* prefix */ + { "" }, /* baseName */ + { "" }, /* namespaceURI */ + { "nshref" }, /* text */ + { "xmlns="nshref"" }, /* xml */ + TRUE, /* todo */ + }, /* no properties or namespaces */ { "<a />", 0, @@ -13755,7 +13767,9 @@ static void test_namespaces_as_attributes(void) { item = NULL; hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); + todo_wine_if(test->todo) ok(SUCCEEDED(hr), "Failed to get item, hr %#lx.\n", hr); + if (FAILED(hr)) continue;
str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str);
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml4/tests/domdoc.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/dlls/msxml4/tests/domdoc.c b/dlls/msxml4/tests/domdoc.c index 66b4610fe0e..93887cc9857 100644 --- a/dlls/msxml4/tests/domdoc.c +++ b/dlls/msxml4/tests/domdoc.c @@ -171,6 +171,7 @@ static void test_namespaces_as_attributes(void) const char *uris[3]; const char *texts[3]; const char *xmls[3]; + BOOL todo; }; static const struct test tests[] = { { @@ -202,6 +203,17 @@ static void test_namespaces_as_attributes(void) { "nshref" }, /* text */ { "xmlns:ns="nshref"" }, /* xml */ }, + /* default namespace */ + { + "<a xmlns="nshref" />", 1, + { "xmlns" }, /* nodeName */ + { "xmlns" }, /* prefix */ + { "" }, /* baseName */ + { "" }, /* namespaceURI */ + { "nshref" }, /* text */ + { "xmlns="nshref"" }, /* xml */ + TRUE, /* todo */ + }, /* no properties or namespaces */ { "<a />", 0, @@ -227,8 +239,8 @@ static void test_namespaces_as_attributes(void) ok(hr == S_OK, "Failed to load xml, hr %#lx.\n", hr);
node = NULL; - hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("a"), &node); - ok(SUCCEEDED(hr), "Failed to select a node, hr %#lx.\n", hr); + hr = IXMLDOMDocument2_get_firstChild(doc, &node); + ok(SUCCEEDED(hr), "Failed to get first child node, hr %#lx.\n", hr);
hr = IXMLDOMNode_get_attributes(node, &map); ok(SUCCEEDED(hr), "Failed to get attributes, hr %#lx.\n", hr); @@ -247,7 +259,9 @@ static void test_namespaces_as_attributes(void) { item = NULL; hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); + todo_wine_if(test->todo) ok(SUCCEEDED(hr), "Failed to get item, hr %#lx.\n", hr); + if (FAILED(hr)) continue;
str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str); @@ -259,8 +273,10 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_prefix(item, &str); if (test->prefixes[i]) { - ok(hr == S_OK, "Failed to get prefix, hr %#lx.\n", hr); - ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str)); + /* MSXML4 can report different results with different service packs */ + ok(hr == S_OK || broken(hr == S_FALSE), "Failed to get prefix, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->prefixes[i])) || broken(!str), + "got %s\n", wine_dbgstr_w(str)); SysFreeString(str); } else @@ -269,7 +285,9 @@ static void test_namespaces_as_attributes(void) str = NULL; hr = IXMLDOMNode_get_baseName(item, &str); ok(SUCCEEDED(hr), "Failed to get base name, hr %#lx.\n", hr); - ok(!lstrcmpW(str, _bstr_(test->basenames[i])), "got %s\n", wine_dbgstr_w(str)); + /* MSXML4 can report different results with different service packs */ + ok(!lstrcmpW(str, _bstr_(test->basenames[i])) || broken(!lstrcmpW(str, L"xmlns")), + "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
str = NULL;
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml6/tests/domdoc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/msxml6/tests/domdoc.c b/dlls/msxml6/tests/domdoc.c index 741a4ff7d09..db1f5a5b9c0 100644 --- a/dlls/msxml6/tests/domdoc.c +++ b/dlls/msxml6/tests/domdoc.c @@ -178,6 +178,7 @@ static void test_namespaces_as_attributes(void) const char *uris[3]; const char *texts[3]; const char *xmls[3]; + BOOL todo; }; static const struct test tests[] = { { @@ -209,6 +210,17 @@ static void test_namespaces_as_attributes(void) { "nshref" }, /* text */ { "xmlns:ns="nshref"" }, /* xml */ }, + /* default namespace */ + { + "<a xmlns="nshref" />", 1, + { "xmlns" }, /* nodeName */ + { NULL }, /* prefix */ + { "xmlns" }, /* baseName */ + { "http://www.w3.org/2000/xmlns/" }, /* namespaceURI */ + { "nshref" }, /* text */ + { "xmlns="nshref"" }, /* xml */ + TRUE, /* todo */ + }, /* no properties or namespaces */ { "<a />", 0, @@ -234,8 +246,8 @@ static void test_namespaces_as_attributes(void) ok(hr == S_OK, "Failed to load xml, hr %#lx.\n", hr);
node = NULL; - hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("a"), &node); - ok(SUCCEEDED(hr), "Failed to select a node, hr %#lx.\n", hr); + hr = IXMLDOMDocument2_get_firstChild(doc, &node); + ok(SUCCEEDED(hr), "Failed to get first child node, hr %#lx.\n", hr);
hr = IXMLDOMNode_get_attributes(node, &map); ok(SUCCEEDED(hr), "Failed to get attributes, hr %#lx.\n", hr); @@ -254,7 +266,9 @@ static void test_namespaces_as_attributes(void) { item = NULL; hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); + todo_wine_if(test->todo) ok(SUCCEEDED(hr), "Failed to get item, hr %#lx.\n", hr); + if (FAILED(hr)) continue;
str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str);
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/element.c | 13 +++++++++---- dlls/msxml3/tests/domdoc.c | 7 +++++-- dlls/msxml4/tests/domdoc.c | 7 +++++-- dlls/msxml6/tests/domdoc.c | 6 ++++-- 4 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/dlls/msxml3/element.c b/dlls/msxml3/element.c index 302849aced6..d2a14fdabcd 100644 --- a/dlls/msxml3/element.c +++ b/dlls/msxml3/element.c @@ -1827,11 +1827,16 @@ static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode * if (attrIndex < index) return S_FALSE;
- xmlns = xmlNewNs(NULL, BAD_CAST "http://www.w3.org/2000/xmlns/", BAD_CAST "xmlns"); - if (!xmlns) - return E_OUTOFMEMORY; + if (!ns->prefix) { + xmlns = NULL; + curr = xmlNewProp(NULL, BAD_CAST "xmlns", ns->href); + } else { + xmlns = xmlNewNs(NULL, BAD_CAST "http://www.w3.org/2000/xmlns/", BAD_CAST "xmlns"); + if (!xmlns) + return E_OUTOFMEMORY;
- curr = xmlNewNsProp(NULL, xmlns, ns->prefix, ns->href); + curr = xmlNewNsProp(NULL, xmlns, ns->prefix, ns->href); + } if (!curr) { xmlFreeNs(xmlns); return E_OUTOFMEMORY; diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 6b63a7c1c3d..d6f5e73c852 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13767,9 +13767,7 @@ static void test_namespaces_as_attributes(void) { item = NULL; hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); - todo_wine_if(test->todo) ok(SUCCEEDED(hr), "Failed to get item, hr %#lx.\n", hr); - if (FAILED(hr)) continue;
str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str); @@ -13781,8 +13779,10 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_prefix(item, &str); if (test->prefixes[i]) { + todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str)); + } SysFreeString(str); } else @@ -13791,6 +13791,7 @@ static void test_namespaces_as_attributes(void) str = NULL; hr = IXMLDOMNode_get_baseName(item, &str); ok(SUCCEEDED(hr), "Failed to get base name, hr %#lx.\n", hr); + todo_wine_if(test->todo) ok(!lstrcmpW(str, _bstr_(test->basenames[i])), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
@@ -13798,11 +13799,13 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { + todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); + } SysFreeString(str); } else diff --git a/dlls/msxml4/tests/domdoc.c b/dlls/msxml4/tests/domdoc.c index 93887cc9857..2f02c99c6aa 100644 --- a/dlls/msxml4/tests/domdoc.c +++ b/dlls/msxml4/tests/domdoc.c @@ -259,9 +259,7 @@ static void test_namespaces_as_attributes(void) { item = NULL; hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); - todo_wine_if(test->todo) ok(SUCCEEDED(hr), "Failed to get item, hr %#lx.\n", hr); - if (FAILED(hr)) continue;
str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str); @@ -274,9 +272,11 @@ static void test_namespaces_as_attributes(void) if (test->prefixes[i]) { /* MSXML4 can report different results with different service packs */ + todo_wine_if(test->todo) { ok(hr == S_OK || broken(hr == S_FALSE), "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])) || broken(!str), "got %s\n", wine_dbgstr_w(str)); + } SysFreeString(str); } else @@ -286,6 +286,7 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_baseName(item, &str); ok(SUCCEEDED(hr), "Failed to get base name, hr %#lx.\n", hr); /* MSXML4 can report different results with different service packs */ + todo_wine_if(test->todo) ok(!lstrcmpW(str, _bstr_(test->basenames[i])) || broken(!lstrcmpW(str, L"xmlns")), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str); @@ -294,11 +295,13 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { + todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); + } SysFreeString(str); } else diff --git a/dlls/msxml6/tests/domdoc.c b/dlls/msxml6/tests/domdoc.c index db1f5a5b9c0..3035a45c350 100644 --- a/dlls/msxml6/tests/domdoc.c +++ b/dlls/msxml6/tests/domdoc.c @@ -266,9 +266,7 @@ static void test_namespaces_as_attributes(void) { item = NULL; hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); - todo_wine_if(test->todo) ok(SUCCEEDED(hr), "Failed to get item, hr %#lx.\n", hr); - if (FAILED(hr)) continue;
str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str); @@ -280,8 +278,10 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_prefix(item, &str); if (test->prefixes[i]) { + todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str)); + } SysFreeString(str); } else @@ -297,12 +297,14 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { + todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/"), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); + } SysFreeString(str); } else
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/node.c | 5 ++++- dlls/msxml3/tests/domdoc.c | 2 +- dlls/msxml4/tests/domdoc.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index 339504477ac..8f560d9a6ce 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -1606,7 +1606,10 @@ HRESULT node_get_base_name(xmlnode *This, BSTR *name) { if (!name) return E_INVALIDARG;
- *name = bstr_from_xmlChar(This->node->name); + if ((xmldoc_version(This->node->doc) != MSXML6) && xmlStrEqual(This->node->name, BAD_CAST "xmlns")) + *name = SysAllocString(L""); + else + *name = bstr_from_xmlChar(This->node->name); if (!*name) return E_OUTOFMEMORY;
TRACE("returning %s\n", debugstr_w(*name)); diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index d6f5e73c852..a95c4b3f700 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13772,6 +13772,7 @@ static void test_namespaces_as_attributes(void) str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str); ok(SUCCEEDED(hr), "Failed to get node name, hr %#lx.\n", hr); + todo_wine_if(test->todo) ok(!lstrcmpW(str, _bstr_(test->names[i])), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
@@ -13791,7 +13792,6 @@ static void test_namespaces_as_attributes(void) str = NULL; hr = IXMLDOMNode_get_baseName(item, &str); ok(SUCCEEDED(hr), "Failed to get base name, hr %#lx.\n", hr); - todo_wine_if(test->todo) ok(!lstrcmpW(str, _bstr_(test->basenames[i])), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
diff --git a/dlls/msxml4/tests/domdoc.c b/dlls/msxml4/tests/domdoc.c index 2f02c99c6aa..fc6b1834fbe 100644 --- a/dlls/msxml4/tests/domdoc.c +++ b/dlls/msxml4/tests/domdoc.c @@ -264,6 +264,7 @@ static void test_namespaces_as_attributes(void) str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str); ok(SUCCEEDED(hr), "Failed to get node name, hr %#lx.\n", hr); + todo_wine_if(test->todo) ok(!lstrcmpW(str, _bstr_(test->names[i])), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
@@ -286,7 +287,6 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_baseName(item, &str); ok(SUCCEEDED(hr), "Failed to get base name, hr %#lx.\n", hr); /* MSXML4 can report different results with different service packs */ - todo_wine_if(test->todo) ok(!lstrcmpW(str, _bstr_(test->basenames[i])) || broken(!lstrcmpW(str, L"xmlns")), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/node.c | 22 ++++++++++++++++++---- dlls/msxml3/tests/domdoc.c | 1 - dlls/msxml4/tests/domdoc.c | 1 - 3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index 8f560d9a6ce..e081b132bea 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -186,6 +186,13 @@ HRESULT node_get_nodeName(xmlnode *This, BSTR *name) hr = node_get_base_name(This, &base); if (hr != S_OK) return hr;
+ if (!base[0] && xmldoc_version(This->node->doc) != MSXML6) + { + SysFreeString(base); + *name = SysAllocString(L"xmlns"); + return S_OK; + } + hr = node_get_prefix(This, &prefix); if (hr == S_OK) { @@ -194,10 +201,17 @@ HRESULT node_get_nodeName(xmlnode *This, BSTR *name)
/* +1 for ':' */ ptr = *name = SysAllocStringLen(NULL, SysStringLen(base) + SysStringLen(prefix) + 1); - memcpy(ptr, prefix, SysStringByteLen(prefix)); - ptr += SysStringLen(prefix); - memcpy(ptr++, &colW, sizeof(WCHAR)); - memcpy(ptr, base, SysStringByteLen(base)); + if (SysStringByteLen(prefix)) + { + memcpy(ptr, prefix, SysStringByteLen(prefix)); + ptr += SysStringLen(prefix); + } + if (SysStringByteLen(base)) + { + if (SysStringByteLen(prefix)) + memcpy(ptr++, &colW, sizeof(WCHAR)); + memcpy(ptr, base, SysStringByteLen(base)); + }
SysFreeString(base); SysFreeString(prefix); diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index a95c4b3f700..d2598820f16 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13772,7 +13772,6 @@ static void test_namespaces_as_attributes(void) str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str); ok(SUCCEEDED(hr), "Failed to get node name, hr %#lx.\n", hr); - todo_wine_if(test->todo) ok(!lstrcmpW(str, _bstr_(test->names[i])), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
diff --git a/dlls/msxml4/tests/domdoc.c b/dlls/msxml4/tests/domdoc.c index fc6b1834fbe..0ca1a0b7b1b 100644 --- a/dlls/msxml4/tests/domdoc.c +++ b/dlls/msxml4/tests/domdoc.c @@ -264,7 +264,6 @@ static void test_namespaces_as_attributes(void) str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str); ok(SUCCEEDED(hr), "Failed to get node name, hr %#lx.\n", hr); - todo_wine_if(test->todo) ok(!lstrcmpW(str, _bstr_(test->names[i])), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/attribute.c | 13 +++++-------- dlls/msxml3/tests/domdoc.c | 2 -- dlls/msxml4/tests/domdoc.c | 2 -- dlls/msxml6/tests/domdoc.c | 2 -- 4 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/dlls/msxml3/attribute.c b/dlls/msxml3/attribute.c index 89a1f630021..6b8c7fba6d9 100644 --- a/dlls/msxml3/attribute.c +++ b/dlls/msxml3/attribute.c @@ -589,14 +589,11 @@ static HRESULT WINAPI domattr_get_prefix(
*prefix = NULL;
- if (ns) - { - /* special case for default namespace definition */ - if (xmlStrEqual(This->node.node->name, xmlns)) - *prefix = bstr_from_xmlChar(xmlns); - else if (ns->prefix) - *prefix = bstr_from_xmlChar(ns->prefix); - } + if (xmlStrEqual(This->node.node->name, xmlns) && + xmldoc_version(This->node.node->doc) != MSXML6) + *prefix = bstr_from_xmlChar(xmlns); + else if (ns && ns->prefix) + *prefix = bstr_from_xmlChar(ns->prefix);
TRACE("prefix: %s\n", debugstr_w(*prefix));
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index d2598820f16..aef056a61b1 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13779,10 +13779,8 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_prefix(item, &str); if (test->prefixes[i]) { - todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else diff --git a/dlls/msxml4/tests/domdoc.c b/dlls/msxml4/tests/domdoc.c index 0ca1a0b7b1b..2880f9b7f37 100644 --- a/dlls/msxml4/tests/domdoc.c +++ b/dlls/msxml4/tests/domdoc.c @@ -272,11 +272,9 @@ static void test_namespaces_as_attributes(void) if (test->prefixes[i]) { /* MSXML4 can report different results with different service packs */ - todo_wine_if(test->todo) { ok(hr == S_OK || broken(hr == S_FALSE), "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])) || broken(!str), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else diff --git a/dlls/msxml6/tests/domdoc.c b/dlls/msxml6/tests/domdoc.c index 3035a45c350..a201ee5deae 100644 --- a/dlls/msxml6/tests/domdoc.c +++ b/dlls/msxml6/tests/domdoc.c @@ -112,10 +112,8 @@ static void test_create_attribute(void) } else { - todo_wine_if(ptr->todo) { ok(hr == S_FALSE, "%d: unexpected hr %#lx\n", i, hr); ok(str == NULL, "%d: got prefix %s\n", i, wine_dbgstr_w(str)); - } } SysFreeString(str);
From: Daniel Lehman dlehman25@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=53531 --- dlls/msxml3/attribute.c | 45 +++++++++++++++++++++++++------------- dlls/msxml3/tests/domdoc.c | 4 ---- dlls/msxml4/tests/domdoc.c | 4 ---- dlls/msxml6/tests/domdoc.c | 12 ++-------- 4 files changed, 32 insertions(+), 33 deletions(-)
diff --git a/dlls/msxml3/attribute.c b/dlls/msxml3/attribute.c index 6b8c7fba6d9..ebab7fdb03a 100644 --- a/dlls/msxml3/attribute.c +++ b/dlls/msxml3/attribute.c @@ -543,10 +543,12 @@ static HRESULT WINAPI domattr_get_namespaceURI( IXMLDOMAttribute *iface, BSTR* p) { - static const WCHAR w3xmlns[] = { 'h','t','t','p',':','/','/', 'w','w','w','.','w','3','.', - 'o','r','g','/','2','0','0','0','/','x','m','l','n','s','/',0 }; + static const WCHAR *w3xmlns = L"http://www.w3.org/2000/xmlns/"; domattr *This = impl_from_IXMLDOMAttribute( iface ); xmlNsPtr ns = This->node.node->ns; + BSTR nodename, pfx; + BOOL is6, isdefault; + HRESULT hr;
TRACE("(%p)->(%p)\n", This, p);
@@ -554,22 +556,35 @@ static HRESULT WINAPI domattr_get_namespaceURI( return E_INVALIDARG;
*p = NULL; + nodename = NULL; + hr = IXMLDOMAttribute_get_nodeName(iface, &nodename); + if (FAILED(hr)) + return hr; + + pfx = NULL; + hr = IXMLDOMAttribute_get_prefix(iface, &pfx); + if (FAILED(hr)) + { + SysFreeString(nodename); + return hr; + }
- if (ns) + is6 = xmldoc_version(This->node.node->doc) == MSXML6; + isdefault = !wcscmp(nodename, L"xmlns"); + if (isdefault || (pfx && !wcscmp(L"xmlns", pfx))) { - /* special case for default namespace definition */ - if (xmlStrEqual(This->node.node->name, xmlns)) - *p = bstr_from_xmlChar(xmlns); - else if (xmlStrEqual(ns->prefix, xmlns)) - { - if (xmldoc_version(This->node.node->doc) == MSXML6) - *p = SysAllocString(w3xmlns); - else - *p = SysAllocStringLen(NULL, 0); - } - else if (ns->href) - *p = bstr_from_xmlChar(ns->href); + if (is6) + *p = SysAllocString(w3xmlns); + else if (!ns || !isdefault) + *p = SysAllocStringLen(NULL, 0); + else + *p = SysAllocString(L"xmlns"); } + else if (ns && ns->href) + *p = bstr_from_xmlChar(ns->href); + + SysFreeString(nodename); + SysFreeString(pfx);
TRACE("uri: %s\n", debugstr_w(*p));
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index aef056a61b1..47719611bdc 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13671,7 +13671,6 @@ static void test_namespaces_as_attributes(void) const char *uris[3]; const char *texts[3]; const char *xmls[3]; - BOOL todo; }; static const struct test tests[] = { { @@ -13712,7 +13711,6 @@ static void test_namespaces_as_attributes(void) { "" }, /* namespaceURI */ { "nshref" }, /* text */ { "xmlns="nshref"" }, /* xml */ - TRUE, /* todo */ }, /* no properties or namespaces */ { @@ -13796,13 +13794,11 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { - todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else diff --git a/dlls/msxml4/tests/domdoc.c b/dlls/msxml4/tests/domdoc.c index 2880f9b7f37..00b9644d0a7 100644 --- a/dlls/msxml4/tests/domdoc.c +++ b/dlls/msxml4/tests/domdoc.c @@ -171,7 +171,6 @@ static void test_namespaces_as_attributes(void) const char *uris[3]; const char *texts[3]; const char *xmls[3]; - BOOL todo; }; static const struct test tests[] = { { @@ -212,7 +211,6 @@ static void test_namespaces_as_attributes(void) { "" }, /* namespaceURI */ { "nshref" }, /* text */ { "xmlns="nshref"" }, /* xml */ - TRUE, /* todo */ }, /* no properties or namespaces */ { @@ -292,13 +290,11 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { - todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else diff --git a/dlls/msxml6/tests/domdoc.c b/dlls/msxml6/tests/domdoc.c index a201ee5deae..467d077d756 100644 --- a/dlls/msxml6/tests/domdoc.c +++ b/dlls/msxml6/tests/domdoc.c @@ -67,12 +67,11 @@ struct attrtest_t { const char *uri; const char *prefix; const char *href; - BOOL todo; };
static struct attrtest_t attrtests[] = { - { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/", TRUE }, - { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/", TRUE }, + { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/" }, + { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/" }, { "c", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/" }, { "c", "nsref1", NULL, "nsref1" }, { "ns:c", "nsref1", "ns", "nsref1" }, @@ -120,7 +119,6 @@ static void test_create_attribute(void) str = NULL; hr = IXMLDOMNode_get_namespaceURI(node, &str); ok(hr == S_OK, "%d: unexpected hr %#lx\n", i, hr); - todo_wine_if(ptr->todo) ok(!lstrcmpW(str, _bstr_(ptr->href)) || broken(!ptr->prefix && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */ "%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), ptr->href); @@ -176,7 +174,6 @@ static void test_namespaces_as_attributes(void) const char *uris[3]; const char *texts[3]; const char *xmls[3]; - BOOL todo; }; static const struct test tests[] = { { @@ -217,7 +214,6 @@ static void test_namespaces_as_attributes(void) { "http://www.w3.org/2000/xmlns/" }, /* namespaceURI */ { "nshref" }, /* text */ { "xmlns="nshref"" }, /* xml */ - TRUE, /* todo */ }, /* no properties or namespaces */ { @@ -276,10 +272,8 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_prefix(item, &str); if (test->prefixes[i]) { - todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else @@ -295,14 +289,12 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { - todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/"), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else
@nsivov copying the tests ballooned the number of commits. trying to combined them seems like it'd make them too big. should i split some of them up and submit separately in smaller batches?
This merge request was closed by Daniel Lehman.