2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/test.h"
28 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
30 static const CLSID CLSID_JScript =
31 {0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
33 static void test_safety(IUnknown *unk)
35 IObjectSafety *safety;
36 DWORD supported, enabled;
39 hres = IUnknown_QueryInterface(unk, &IID_IObjectSafety, (void**)&safety);
40 ok(hres == S_OK, "Could not get IObjectSafety: %08x\n", hres);
44 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, &supported, NULL);
45 ok(hres == E_POINTER, "GetInterfaceSafetyOptions failed: %08x, expected E_POINTER\n", hres);
46 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, NULL, &enabled);
47 ok(hres == E_POINTER, "GetInterfaceSafetyOptions failed: %08x, expected E_POINTER\n", hres);
49 supported = enabled = 0xdeadbeef;
50 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, &supported, &enabled);
51 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
52 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
53 "supported=%x\n", supported);
54 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
56 supported = enabled = 0xdeadbeef;
57 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScript, &supported, &enabled);
58 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
59 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
60 "supported=%x\n", supported);
61 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
63 supported = enabled = 0xdeadbeef;
64 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
65 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
66 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
67 "supported=%x\n", supported);
68 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
70 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
71 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER
72 |INTERFACESAFE_FOR_UNTRUSTED_CALLER,
73 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER);
74 ok(hres == E_FAIL, "SetInterfaceSafetyOptions failed: %08x, expected E_FAIL\n", hres);
76 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
77 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER,
78 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER);
79 ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
81 supported = enabled = 0xdeadbeef;
82 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
83 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
84 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
85 "supported=%x\n", supported);
86 ok(enabled == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
87 "enabled=%x\n", enabled);
89 IObjectSafety_Release(safety);
92 static void test_jscript(void)
94 IActiveScriptParse *parse;
95 IActiveScript *script;
99 hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
100 &IID_IUnknown, (void**)&unk);
101 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
105 hres = IUnknown_QueryInterface(unk, &IID_IActiveScript, (void**)&script);
106 ok(hres == S_OK, "Could not get IActiveScript: %08x\n", hres);
108 hres = IUnknown_QueryInterface(unk, &IID_IActiveScriptParse, (void**)&parse);
109 ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
113 IActiveScriptParse_Release(parse);
114 IActiveScript_Release(script);
115 IUnknown_Release(unk);