Signed-off-by: Daniel Lehman dlehman25@gmail.com --- v2: use shlwapi --- dlls/msxml3/domdoc.c | 2 +- dlls/msxml3/tests/Makefile.in | 2 +- dlls/msxml3/tests/domdoc.c | 56 +++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index 76d3fdb601..c86a4931c5 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -2276,7 +2276,7 @@ static HRESULT WINAPI domdoc_load(
if (hr == S_OK) { - hr = domdoc_load_from_stream(This, stream); + hr = This->error = domdoc_load_from_stream(This, stream); if (hr == S_OK) *isSuccessful = VARIANT_TRUE; ISequentialStream_Release(stream); diff --git a/dlls/msxml3/tests/Makefile.in b/dlls/msxml3/tests/Makefile.in index c397295142..bc1f051b09 100644 --- a/dlls/msxml3/tests/Makefile.in +++ b/dlls/msxml3/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = msxml3.dll -IMPORTS = oleaut32 ole32 user32 +IMPORTS = oleaut32 ole32 user32 shlwapi
C_SRCS = \ domdoc.c \ diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 49768b8dbe..0ebc5165a3 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -37,8 +37,10 @@ #include "dispex.h" #include "objsafe.h" #include "mshtml.h" +#include "xmlparser.h" #include "initguid.h" #include "asptlb.h" +#include "shlwapi.h"
#include "wine/heap.h" #include "wine/test.h" @@ -700,6 +702,36 @@ static void _expect_list_len(IXMLDOMNodeList *list, LONG len, int line) #define EXPECT_HR(hr,hr_exp) \ ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
+#define EXPECT_PARSE_ERROR(doc, hr_exp, hr_todo) _expect_parse_error(doc, hr_exp, hr_todo, __LINE__) +static void _expect_parse_error(IXMLDOMDocument *doc, HRESULT hr_exp, BOOL hr_todo, int line) +{ + IXMLDOMParseError *error; + HRESULT hr; + LONG code; + + error = NULL; + hr = IXMLDOMDocument_get_parseError(doc, &error); + ok_(__FILE__,line)(hr == S_OK, "got 0x%08x\n", hr); + ok_(__FILE__,line)(!!error, "got NULL parseError\n"); + + code = 0xdeadbeef; + hr = IXMLDOMParseError_get_errorCode(error, &code); + if (FAILED(hr_exp)) + { + ok_(__FILE__,line)(hr == S_OK, "got 0x%08x\n", hr); + ok_(__FILE__,line)(FAILED(code), "expected failure HRESULT\n"); + todo_wine_if(hr_todo) + ok_(__FILE__,line)(hr_exp == code, "expected 0x%08x, got 0x%08x\n", hr_exp, code); + } + else + { + ok_(__FILE__,line)(hr == S_FALSE, "got 0x%08x\n", hr); + ok_(__FILE__,line)(SUCCEEDED(code), "expected successful HRESULT\n"); + } + + IXMLDOMParseError_Release(error); +} + static const WCHAR szEmpty[] = { 0 }; static const WCHAR szIncomplete[] = { '<','?','x','m','l',' ', @@ -10242,6 +10274,7 @@ static void test_load(void) IXMLDOMNodeList *list; IXMLDOMDocument *doc; BSTR bstr1, bstr2; + IStream *stream; VARIANT_BOOL b; VARIANT src; HRESULT hr; @@ -10419,6 +10452,29 @@ static void test_load(void) ok(b == VARIANT_FALSE, "got %d\n", b);
VariantClear(&src); + + /* test istream with empty content */ + stream = SHCreateMemStream((const BYTE*)nocontent, strlen(nocontent)); + V_VT(&src) = VT_UNKNOWN; + V_UNKNOWN(&src) = (IUnknown*)stream; + b = VARIANT_TRUE; + hr = IXMLDOMDocument_load(doc, src, &b); + todo_wine ok(hr == S_FALSE, "got 0x%08x\n", hr); + ok(b == VARIANT_FALSE, "got %d\n", b); + EXPECT_PARSE_ERROR(doc, XML_E_INVALIDATROOTLEVEL, TRUE); + VariantClear(&src); + + /* test istream with valid xml */ + stream = SHCreateMemStream((const BYTE*)complete4A, strlen(complete4A)); + V_VT(&src) = VT_UNKNOWN; + V_UNKNOWN(&src) = (IUnknown*)stream; + b = VARIANT_FALSE; + hr = IXMLDOMDocument_load(doc, src, &b); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(b == VARIANT_TRUE, "got %d\n", b); + EXPECT_PARSE_ERROR(doc, S_OK, FALSE); + VariantClear(&src); + IXMLDOMDocument_Release(doc);
free_bstrs();
Signed-off-by: Daniel Lehman dlehman25@gmail.com --- v2: use shlwapi --- dlls/msxml3/domdoc.c | 2 +- dlls/msxml3/tests/domdoc.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index c86a4931c5..b740b2e9d3 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -824,7 +824,7 @@ static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, IStream if (!stream) return E_INVALIDARG;
- return domdoc_load_from_stream(This, (ISequentialStream*)stream); + return This->error = domdoc_load_from_stream(This, (ISequentialStream*)stream); }
static HRESULT WINAPI PersistStreamInit_Save( diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 0ebc5165a3..ef29bf6a59 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -2181,6 +2181,7 @@ static void test_persiststream(void) IXMLDOMDocument *doc; ULARGE_INTEGER size; IPersist *persist; + IStream *istream; HRESULT hr; CLSID clsid;
@@ -2214,6 +2215,21 @@ static void test_persiststream(void) ok(IsEqualGUID(&clsid, &CLSID_DOMDocument2), "wrong clsid %s\n", wine_dbgstr_guid(&clsid));
IPersistStream_Release(stream); + + /* test Load */ + istream = SHCreateMemStream((const BYTE*)complete4A, strlen(complete4A)); + hr = IPersistStreamInit_Load(streaminit, istream); + ok(hr == S_OK, "got 0x%08x\n", hr); + IStream_Release(istream); + EXPECT_PARSE_ERROR(doc, S_OK, FALSE); + + istream = SHCreateMemStream((const BYTE*)"", 0); + hr = IPersistStreamInit_Load(streaminit, istream); + todo_wine ok(hr == XML_E_MISSINGROOT, "got 0x%08x\n", hr); + ok(FAILED(hr), "got success\n"); + IStream_Release(istream); + EXPECT_PARSE_ERROR(doc, XML_E_MISSINGROOT, TRUE); + IPersistStreamInit_Release(streaminit); IXMLDOMDocument_Release(doc); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com