msxml3: Accept IObjectSafety for query from IXMLDOMDocument, fix its implementation.

This commit is contained in:
Nikolay Sivov 2010-02-19 13:46:16 +03:00 committed by Alexandre Julliard
parent 1ff9923148
commit b679a690b4
2 changed files with 76 additions and 7 deletions

View File

@ -471,6 +471,10 @@ static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument2 *iface, REFIID rii
{
*ppvObject = &(This->lpvtblIObjectWithSite);
}
else if (IsEqualGUID(&IID_IObjectSafety, riid))
{
*ppvObject = &(This->lpvtblIObjectSafety);
}
else if( IsEqualGUID( riid, &IID_ISupportErrorInfo ))
{
*ppvObject = &This->lpvtblISupportErrorInfo;
@ -2210,7 +2214,7 @@ static ULONG WINAPI xmldoc_Safety_Release(IObjectSafety *iface)
return IXMLDocument_Release((IXMLDocument *)This);
}
#define SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_SECURITY_MANAGER)
#define SAFETY_SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA)
static HRESULT WINAPI xmldoc_Safety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
@ -2222,7 +2226,7 @@ static HRESULT WINAPI xmldoc_Safety_GetInterfaceSafetyOptions(IObjectSafety *ifa
if(!pdwSupportedOptions || !pdwEnabledOptions)
return E_POINTER;
*pdwSupportedOptions = SUPPORTED_OPTIONS;
*pdwSupportedOptions = SAFETY_SUPPORTED_OPTIONS;
*pdwEnabledOptions = This->safeopt;
return S_OK;
@ -2232,13 +2236,9 @@ static HRESULT WINAPI xmldoc_Safety_SetInterfaceSafetyOptions(IObjectSafety *ifa
DWORD dwOptionSetMask, DWORD dwEnabledOptions)
{
domdoc *This = impl_from_IObjectSafety(iface);
TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions);
if(dwOptionSetMask & ~SUPPORTED_OPTIONS)
return E_FAIL;
This->safeopt = dwEnabledOptions & dwEnabledOptions;
This->safeopt = dwEnabledOptions & dwOptionSetMask & SAFETY_SUPPORTED_OPTIONS;
return S_OK;
}

View File

@ -24,6 +24,7 @@
#include "windows.h"
#include "ole2.h"
#include "objsafe.h"
#include "xmldom.h"
#include "msxml2.h"
#include "msxml2did.h"
@ -33,6 +34,10 @@
#include "wine/test.h"
#include "initguid.h"
DEFINE_GUID(IID_IObjectSafety, 0xcb5bdc81, 0x93c1, 0x11cf, 0x8f,0x20, 0x00,0x80,0x5f,0x2c,0xd0,0x64);
static const WCHAR szEmpty[] = { 0 };
static const WCHAR szIncomplete[] = {
'<','?','x','m','l',' ',
@ -5284,6 +5289,69 @@ static void test_put_nodeValue(void)
IXMLDOMDocument_Release(doc);
}
static void test_document_IObjectSafety(void)
{
IXMLDOMDocument *doc;
IObjectSafety *safety;
DWORD enabled = 0, supported = 0;
HRESULT hr;
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
if( hr != S_OK )
return;
hr = IXMLDOMDocument_QueryInterface(doc, &IID_IObjectSafety, (void**)&safety);
ok(hr == S_OK, "ret %08x\n", hr );
/* get */
hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, NULL, &enabled);
ok(hr == E_POINTER, "ret %08x\n", hr );
hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, NULL);
ok(hr == E_POINTER, "ret %08x\n", hr );
hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled);
ok(hr == S_OK, "ret %08x\n", hr );
ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA),
"Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA),"
"got %08x\n", supported);
ok(enabled == 0, "Expected 0, got %08x\n", enabled);
/* set */
hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL,
INTERFACESAFE_FOR_UNTRUSTED_CALLER,
INTERFACESAFE_FOR_UNTRUSTED_CALLER);
ok(hr == S_OK, "ret %08x\n", hr );
hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled);
ok(hr == S_OK, "ret %08x\n", hr );
ok(enabled == INTERFACESAFE_FOR_UNTRUSTED_CALLER,
"Expected INTERFACESAFE_FOR_UNTRUSTED_CALLER, got %08x\n", enabled);
/* set unsupported */
hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL,
INTERFACE_USES_SECURITY_MANAGER |
INTERFACESAFE_FOR_UNTRUSTED_CALLER,
INTERFACE_USES_SECURITY_MANAGER);
ok(hr == S_OK, "ret %08x\n", hr );
hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled);
ok(hr == S_OK, "ret %08x\n", hr );
ok(enabled == 0, "Expected 0, got %08x\n", enabled);
hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL,
INTERFACESAFE_FOR_UNTRUSTED_CALLER,
INTERFACESAFE_FOR_UNTRUSTED_CALLER);
ok(hr == S_OK, "ret %08x\n", hr );
hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL,
INTERFACESAFE_FOR_UNTRUSTED_DATA,
INTERFACESAFE_FOR_UNTRUSTED_DATA);
ok(hr == S_OK, "ret %08x\n", hr );
hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled);
ok(hr == S_OK, "ret %08x\n", hr );
ok(enabled == INTERFACESAFE_FOR_UNTRUSTED_DATA,
"Expected INTERFACESAFE_FOR_UNTRUSTED_DATA, got %08x\n", enabled);
IObjectSafety_Release(safety);
IXMLDOMDocument_Release(doc);
}
START_TEST(domdoc)
{
HRESULT r;
@ -5315,6 +5383,7 @@ START_TEST(domdoc)
test_NodeTypeValue();
test_TransformWithLoadingLocalFile();
test_put_nodeValue();
test_document_IObjectSafety();
CoUninitialize();
}