From: Daniel Lehman dlehman25@gmail.com
Based on patch from Damjan Jovanovic damjan.jov@gmail.com --- dlls/msxml3/tests/domdoc.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index cf9fb62a65e..8368afa09a1 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -50,6 +50,15 @@ /* undef the #define in msxml2 so that we can access all versions */ #undef CLSID_DOMDocument
+typedef enum { + MSXML1 = 0x01, + MSXML2 = 0x02, + MSXML26 = 0x04, + MSXML3 = 0x08, + MSXML4 = 0x10, + MSXML6 = 0x20 +} MSXML_VERSION; + DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); DEFINE_GUID(IID_transformdest_unknown,0xf5078f3a,0xc551,0x11d3,0x89,0xb9,0x00,0x00,0xf8,0x1f,0xe2,0x21);
@@ -13648,16 +13657,17 @@ todo_wine { typedef struct _namespace_as_attribute_t { const GUID *guid; const char *clsid; + MSXML_VERSION ver; 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", MSXML1, "" }, + { &CLSID_DOMDocument2, "CLSID_DOMDocument2", MSXML2, "" }, + { &CLSID_DOMDocument26, "CLSID_DOMDocument26", MSXML26, "" }, + { &CLSID_DOMDocument30, "CLSID_DOMDocument30", MSXML3, "" }, + { &CLSID_DOMDocument40, "CLSID_DOMDocument40", MSXML4, "" }, + { &CLSID_DOMDocument60, "CLSID_DOMDocument60", MSXML6, "http://www.w3.org/2000/xmlns/" }, { 0 } };
@@ -13672,6 +13682,7 @@ static void test_namespaces_as_attributes(void) const char *basenames[3]; const char *uris[3]; const char *texts[3]; + MSXML_VERSION versions; }; static const struct test tests[] = { { @@ -13725,7 +13736,13 @@ static void test_namespaces_as_attributes(void) }
test = tests; - while (test->xml) { + while (test->xml) + { + if (test->versions && !(entry->ver & test->versions)) + { + test++; + continue; + } hr = CoCreateInstance(entry->guid, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc); ok(SUCCEEDED(hr), "Failed to create document %s, hr %#lx.\n", wine_dbgstr_guid(entry->guid), hr);
@@ -13733,7 +13750,7 @@ static void test_namespaces_as_attributes(void) ok(hr == S_OK, "Failed to load xml, hr %#lx.\n", hr);
node = NULL; - hr = IXMLDOMDocument_selectSingleNode(doc, _bstr_("a"), &node); + hr = IXMLDOMDocument_get_firstChild(doc, &node); ok(SUCCEEDED(hr), "Failed to select a node, hr %#lx.\n", hr);
hr = IXMLDOMNode_get_attributes(node, &map);
From: Daniel Lehman dlehman25@gmail.com
Based on patch from Damjan Jovanovic damjan.jov@gmail.com --- dlls/msxml3/tests/domdoc.c | 40 +++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 8368afa09a1..00d31399ca3 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13683,6 +13683,7 @@ static void test_namespaces_as_attributes(void) const char *uris[3]; const char *texts[3]; MSXML_VERSION versions; + BOOL todo; }; static const struct test tests[] = { { @@ -13711,6 +13712,27 @@ static void test_namespaces_as_attributes(void) { "" }, /* namespaceURI */ { "nshref" }, /* text */ }, + /* default namespace */ + { + "<a xmlns="nshref" />", 1, + { "xmlns" }, /* nodeName */ + { "xmlns" }, /* prefix */ + { "" }, /* baseName */ + { "" }, /* namespaceURI */ + { "nshref" }, /* text */ + ~MSXML6, /* versions */ + TRUE, /* todo */ + }, + { + "<a xmlns="nshref" />", 1, + { "xmlns" }, /* nodeName */ + { NULL }, /* prefix */ + { "xmlns" }, /* baseName */ + { "http://www.w3.org/2000/xmlns/" }, /* namespaceURI */ + { "nshref" }, /* text */ + MSXML6, /* versions */ + TRUE, /* todo */ + }, /* no properties or namespaces */ { "<a />", 0, @@ -13770,7 +13792,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); @@ -13782,24 +13806,30 @@ 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(!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(entry->ver == MSXML4 && hr == S_FALSE), + "Failed to get prefix, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(test->prefixes[i])) || + broken(!str && entry->ver == MSXML4), "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, "Failed to get prefix, 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)); + /* MSXML4 can report different results with different service packs */ + ok(!lstrcmpW(str, _bstr_(test->basenames[i])) || + broken(entry->ver == MSXML4 && !lstrcmpW(str, L"xmlns")), + "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 node name, hr %#lx.\n", hr); + ok(hr == S_OK, "Failed to get node 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
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/tests/domdoc.c | 46 ++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 00d31399ca3..a8b125b54a5 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13682,6 +13682,7 @@ static void test_namespaces_as_attributes(void) const char *basenames[3]; const char *uris[3]; const char *texts[3]; + const char *xmls[3]; MSXML_VERSION versions; BOOL todo; }; @@ -13693,35 +13694,39 @@ 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 */ }, /* default namespace */ { "<a xmlns="nshref" />", 1, - { "xmlns" }, /* nodeName */ - { "xmlns" }, /* prefix */ - { "" }, /* baseName */ - { "" }, /* namespaceURI */ - { "nshref" }, /* text */ - ~MSXML6, /* versions */ - TRUE, /* todo */ + { "xmlns" }, /* nodeName */ + { "xmlns" }, /* prefix */ + { "" }, /* baseName */ + { "" }, /* namespaceURI */ + { "nshref" }, /* text */ + { "xmlns="nshref"" }, /* xml */ + ~MSXML6, /* versions */ + TRUE, /* todo */ }, { "<a xmlns="nshref" />", 1, @@ -13730,6 +13735,7 @@ static void test_namespaces_as_attributes(void) { "xmlns" }, /* baseName */ { "http://www.w3.org/2000/xmlns/" }, /* namespaceURI */ { "nshref" }, /* text */ + { "xmlns="nshref"" }, /* xml */ MSXML6, /* versions */ TRUE, /* todo */ }, @@ -13845,6 +13851,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
--- dlls/msxml3/tests/domdoc.c | 160 ++++++++++++++++++++++++------------- 1 file changed, 105 insertions(+), 55 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index a8b125b54a5..964addf90d1 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13318,22 +13318,45 @@ struct attrtest_t { const char *uri; const char *prefix; const char *href; + MSXML_VERSION versions; + BOOL todo; };
static struct attrtest_t attrtests[] = { - { "xmlns", "http://www.w3.org/2000/xmlns/", "xmlns", "xmlns" }, - { "xmlns", "nondefaulturi", "xmlns", "xmlns" }, + { "xmlns", "http://www.w3.org/2000/xmlns/", "xmlns", "xmlns", ~MSXML6 }, + { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/", MSXML6, TRUE }, + { "xmlns", "nondefaulturi", "xmlns", "xmlns", ~MSXML6 }, + { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/", MSXML6, 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", "" }, - { "xmlns:c", "nondefaulturi", "xmlns", "" }, + { "xmlns:c", "http://www.w3.org/2000/xmlns/", "xmlns", "", ~MSXML6 }, + { "xmlns:c", "http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2000/xmlns/", MSXML6 }, + { "xmlns:c", "nondefaulturi", "xmlns", "", ~MSXML6 }, + { "xmlns:c", "nondefaulturi", "xmlns", "http://www.w3.org/2000/xmlns/", MSXML6 }, + { 0 } +}; + +typedef struct _create_attribute { + const GUID *guid; + const char *clsid; + MSXML_VERSION ver; +} create_attribute; + +static const create_attribute create_attribute_test_data[] = { + { &CLSID_DOMDocument, "CLSID_DOMDocument", MSXML1 }, + { &CLSID_DOMDocument2, "CLSID_DOMDocument2", MSXML2 }, + { &CLSID_DOMDocument26, "CLSID_DOMDocument26", MSXML26 }, + { &CLSID_DOMDocument30, "CLSID_DOMDocument30", MSXML3 }, + { &CLSID_DOMDocument40, "CLSID_DOMDocument40", MSXML4 }, + { &CLSID_DOMDocument60, "CLSID_DOMDocument60", MSXML6 }, { 0 } };
static void test_create_attribute(void) { - struct attrtest_t *ptr = attrtests; + const create_attribute *entry = create_attribute_test_data; + struct attrtest_t *ptr; IXMLDOMElement *el; IXMLDOMDocument *doc; IXMLDOMNode *node, *node2; @@ -13342,69 +13365,96 @@ static void test_create_attribute(void) int i = 0; BSTR str;
- doc = create_document(&IID_IXMLDOMDocument); - - while (ptr->name) + while (entry->guid) { - V_VT(&var) = VT_I1; - V_I1(&var) = NODE_ATTRIBUTE; - hr = IXMLDOMDocument_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) + if (!is_clsid_supported(entry->guid, &IID_IXMLDOMDocument2)) { - 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); + entry++; + continue; } - else + + ptr = attrtests; + while (ptr->name) { - 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); + if (ptr->versions && !(entry->ver & ptr->versions)) + { + ptr++; + continue; + } + hr = CoCreateInstance(entry->guid, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc); + ok(SUCCEEDED(hr), "Failed to create document %s, hr %#lx.\n", wine_dbgstr_guid(entry->guid), hr);
- 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); + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + hr = IXMLDOMDocument_createNode(doc, var, _bstr_(ptr->name), _bstr_(ptr->uri), &node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IXMLDOMNode_Release(node); - free_bstrs(); + 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(entry->ver == MSXML4 && hr == S_FALSE), + "Failed to get prefix, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(ptr->prefix)) || + broken(!str && entry->ver == MSXML4), "got %s\n", wine_dbgstr_w(str)); + } + 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);
- i++; - ptr++; - } + 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 && entry->ver == MSXML6 && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */ + "%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), ptr->href); + SysFreeString(str);
- V_VT(&var) = VT_I1; - V_I1(&var) = NODE_ELEMENT; - hr = IXMLDOMDocument_createNode(doc, var, _bstr_("e"), NULL, &node2); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IXMLDOMNode_Release(node); + free_bstrs();
- hr = IXMLDOMNode_QueryInterface(node2, &IID_IXMLDOMElement, (void**)&el); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - IXMLDOMNode_Release(node2); + i++; + ptr++; + }
- V_VT(&var) = VT_I1; - V_I1(&var) = NODE_ATTRIBUTE; - hr = IXMLDOMDocument_createNode(doc, var, _bstr_("xmlns:a"), _bstr_("http://www.w3.org/2000/xmlns/"), &node); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ELEMENT; + hr = IXMLDOMDocument_createNode(doc, var, _bstr_("e"), NULL, &node2); + 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); + hr = IXMLDOMNode_QueryInterface(node2, &IID_IXMLDOMElement, (void**)&el); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IXMLDOMNode_Release(node2);
- /* 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); + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + hr = IXMLDOMDocument_createNode(doc, var, _bstr_("xmlns:a"), _bstr_("http://www.w3.org/2000/xmlns/"), &node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IXMLDOMNode_Release(node); - IXMLDOMElement_Release(el); - IXMLDOMDocument_Release(doc); - free_bstrs(); + 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, entry->ver == MSXML6 ? L"http://www.w3.org/2000/xmlns/" : L""), + "got uri %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + IXMLDOMNode_Release(node); + IXMLDOMElement_Release(el); + IXMLDOMDocument_Release(doc); + free_bstrs(); + + entry++; + } }
static void test_url(void)
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/element.c | 13 +++++++++---- dlls/msxml3/tests/domdoc.c | 9 +++++++-- 2 files changed, 16 insertions(+), 6 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 964addf90d1..f20538e0c27 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13735,6 +13735,7 @@ static void test_namespaces_as_attributes(void) const char *xmls[3]; MSXML_VERSION versions; BOOL todo; + BOOL todo2; }; static const struct test tests[] = { { @@ -13777,6 +13778,7 @@ static void test_namespaces_as_attributes(void) { "xmlns="nshref"" }, /* xml */ ~MSXML6, /* versions */ TRUE, /* todo */ + TRUE, /* todo2 */ }, { "<a xmlns="nshref" />", 1, @@ -13848,9 +13850,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); @@ -13863,10 +13863,12 @@ 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(entry->ver == MSXML4 && hr == S_FALSE), "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])) || broken(!str && entry->ver == MSXML4), "got %s\n", wine_dbgstr_w(str)); + } SysFreeString(str); } else @@ -13876,6 +13878,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->todo2) ok(!lstrcmpW(str, _bstr_(test->basenames[i])) || broken(entry->ver == MSXML4 && !lstrcmpW(str, L"xmlns")), "got %s\n", wine_dbgstr_w(str)); @@ -13885,11 +13888,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 node 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 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 +- 2 files changed, 5 insertions(+), 2 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 f20538e0c27..53584c2758d 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13855,6 +13855,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->todo2) ok(!lstrcmpW(str, _bstr_(test->names[i])), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
@@ -13878,7 +13879,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->todo2) ok(!lstrcmpW(str, _bstr_(test->basenames[i])) || broken(entry->ver == MSXML4 && !lstrcmpW(str, L"xmlns")), "got %s\n", wine_dbgstr_w(str));
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/node.c | 22 ++++++++++++++++++---- dlls/msxml3/tests/domdoc.c | 3 --- 2 files changed, 18 insertions(+), 7 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 53584c2758d..526941b0620 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13735,7 +13735,6 @@ static void test_namespaces_as_attributes(void) const char *xmls[3]; MSXML_VERSION versions; BOOL todo; - BOOL todo2; }; static const struct test tests[] = { { @@ -13778,7 +13777,6 @@ static void test_namespaces_as_attributes(void) { "xmlns="nshref"" }, /* xml */ ~MSXML6, /* versions */ TRUE, /* todo */ - TRUE, /* todo2 */ }, { "<a xmlns="nshref" />", 1, @@ -13855,7 +13853,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->todo2) 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 | 4 ---- 2 files changed, 5 insertions(+), 12 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 526941b0620..29bcf7abd45 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13401,10 +13401,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);
@@ -13861,12 +13859,10 @@ 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(entry->ver == MSXML4 && hr == S_FALSE), "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])) || broken(!str && entry->ver == MSXML4), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/attribute.c | 45 +++++++++++++++++++++++++------------- dlls/msxml3/tests/domdoc.c | 8 ++----- 2 files changed, 32 insertions(+), 21 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 29bcf7abd45..dcc131afa9d 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13319,14 +13319,13 @@ struct attrtest_t { const char *prefix; const char *href; MSXML_VERSION versions; - BOOL todo; };
static struct attrtest_t attrtests[] = { { "xmlns", "http://www.w3.org/2000/xmlns/", "xmlns", "xmlns", ~MSXML6 }, - { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/", MSXML6, TRUE }, + { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/", MSXML6 }, { "xmlns", "nondefaulturi", "xmlns", "xmlns", ~MSXML6 }, - { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/", MSXML6, TRUE }, + { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/", MSXML6 }, { "c", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/" }, { "c", "nsref1", NULL, "nsref1" }, { "ns:c", "nsref1", "ns", "nsref1" }, @@ -13409,7 +13408,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 && entry->ver == MSXML6 && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */ "%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), ptr->href); @@ -13881,13 +13879,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 node 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 ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else
@nsivov i didn't see this in the regressions list, but it's a regression from a previous change i made. this ok to go in for 8.0?