2008-03-24 21:53:14 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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
|
2008-09-01 01:19:25 +02:00
|
|
|
#define CONST_VTABLE
|
2008-03-24 21:53:14 +01:00
|
|
|
|
2008-07-08 16:17:17 +02:00
|
|
|
#include <initguid.h>
|
2008-03-24 21:53:14 +01:00
|
|
|
#include <ole2.h>
|
|
|
|
#include <activscp.h>
|
2008-04-10 10:37:17 +02:00
|
|
|
#include <objsafe.h>
|
2008-09-01 01:23:38 +02:00
|
|
|
#include <dispex.h>
|
2008-03-24 21:53:14 +01:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
#ifdef _WIN64
|
|
|
|
|
|
|
|
#define IActiveScriptParse_QueryInterface IActiveScriptParse64_QueryInterface
|
|
|
|
#define IActiveScriptParse_Release IActiveScriptParse64_Release
|
|
|
|
#define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew
|
|
|
|
#define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText
|
2019-12-12 13:54:03 +01:00
|
|
|
#define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_64_Release
|
|
|
|
#define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_64_ParseProcedureText
|
2012-07-30 12:02:01 +02:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define IActiveScriptParse_QueryInterface IActiveScriptParse32_QueryInterface
|
|
|
|
#define IActiveScriptParse_Release IActiveScriptParse32_Release
|
|
|
|
#define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew
|
|
|
|
#define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText
|
2019-12-12 13:54:03 +01:00
|
|
|
#define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_32_Release
|
|
|
|
#define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_32_ParseProcedureText
|
2012-07-30 12:02:01 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-07-08 16:17:17 +02:00
|
|
|
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
2019-12-12 13:54:03 +01:00
|
|
|
DEFINE_GUID(IID_IScriptTypeInfo, 0xc59c6b12, 0xf6c1, 0x11cf, 0x88,0x35, 0x00,0xa0,0xc9,0x11,0xe8,0xb2);
|
2008-07-08 16:17:17 +02:00
|
|
|
|
2008-03-24 21:53:14 +01:00
|
|
|
static const CLSID CLSID_JScript =
|
|
|
|
{0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
|
2012-03-26 11:42:13 +02:00
|
|
|
static const CLSID CLSID_JScriptEncode =
|
|
|
|
{0xf414c262,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
|
2008-03-24 21:53:14 +01:00
|
|
|
|
2008-09-01 01:19:25 +02:00
|
|
|
#define DEFINE_EXPECT(func) \
|
2019-11-07 18:17:20 +01:00
|
|
|
static int expect_ ## func = 0, called_ ## func = 0
|
2008-09-01 01:19:25 +02:00
|
|
|
|
|
|
|
#define SET_EXPECT(func) \
|
2019-11-07 18:17:20 +01:00
|
|
|
expect_ ## func = 1
|
2008-09-01 01:19:25 +02:00
|
|
|
|
2019-11-07 18:17:28 +01:00
|
|
|
#define SET_EXPECT_MULTI(func, num) \
|
|
|
|
expect_ ## func = num
|
|
|
|
|
2008-09-01 01:19:25 +02:00
|
|
|
#define CHECK_EXPECT2(func) \
|
|
|
|
do { \
|
|
|
|
ok(expect_ ##func, "unexpected call " #func "\n"); \
|
2019-11-07 18:17:20 +01:00
|
|
|
called_ ## func++; \
|
2008-09-01 01:19:25 +02:00
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_EXPECT(func) \
|
|
|
|
do { \
|
|
|
|
CHECK_EXPECT2(func); \
|
2019-11-07 18:17:20 +01:00
|
|
|
expect_ ## func--; \
|
2008-09-01 01:19:25 +02:00
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_CALLED(func) \
|
|
|
|
do { \
|
|
|
|
ok(called_ ## func, "expected " #func "\n"); \
|
2019-11-07 18:17:20 +01:00
|
|
|
expect_ ## func = called_ ## func = 0; \
|
2008-09-01 01:19:25 +02:00
|
|
|
}while(0)
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
#define CHECK_NOT_CALLED(func) \
|
|
|
|
do { \
|
|
|
|
ok(!called_ ## func, "unexpected " #func "\n"); \
|
|
|
|
expect_ ## func = called_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
2019-11-07 18:17:28 +01:00
|
|
|
#define CHECK_CALLED_MULTI(func, num) \
|
|
|
|
do { \
|
|
|
|
ok(called_ ## func == num, "expected " #func " %d times (got %d)\n", num, called_ ## func); \
|
|
|
|
expect_ ## func = called_ ## func = 0; \
|
|
|
|
}while(0)
|
|
|
|
|
2008-09-01 01:19:25 +02:00
|
|
|
DEFINE_EXPECT(GetLCID);
|
2011-02-21 17:49:32 +01:00
|
|
|
DEFINE_EXPECT(OnStateChange_UNINITIALIZED);
|
2008-09-01 01:19:25 +02:00
|
|
|
DEFINE_EXPECT(OnStateChange_STARTED);
|
2008-11-05 01:03:19 +01:00
|
|
|
DEFINE_EXPECT(OnStateChange_CONNECTED);
|
|
|
|
DEFINE_EXPECT(OnStateChange_DISCONNECTED);
|
2008-09-01 01:19:25 +02:00
|
|
|
DEFINE_EXPECT(OnStateChange_CLOSED);
|
|
|
|
DEFINE_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
DEFINE_EXPECT(OnEnterScript);
|
|
|
|
DEFINE_EXPECT(OnLeaveScript);
|
2020-03-05 17:12:03 +01:00
|
|
|
DEFINE_EXPECT(OnScriptError);
|
|
|
|
DEFINE_EXPECT(GetIDsOfNames);
|
2020-03-27 18:34:08 +01:00
|
|
|
DEFINE_EXPECT(GetIDsOfNames_visible);
|
2020-03-24 17:49:58 +01:00
|
|
|
DEFINE_EXPECT(GetIDsOfNames_persistent);
|
2020-03-05 17:12:03 +01:00
|
|
|
DEFINE_EXPECT(GetItemInfo_global);
|
|
|
|
DEFINE_EXPECT(GetItemInfo_global_code);
|
|
|
|
DEFINE_EXPECT(GetItemInfo_visible);
|
|
|
|
DEFINE_EXPECT(GetItemInfo_visible_code);
|
2020-03-24 17:49:58 +01:00
|
|
|
DEFINE_EXPECT(GetItemInfo_persistent);
|
2020-03-05 17:12:03 +01:00
|
|
|
DEFINE_EXPECT(testCall);
|
2008-09-01 01:19:25 +02:00
|
|
|
|
2012-03-26 11:42:13 +02:00
|
|
|
static const CLSID *engine_clsid = &CLSID_JScript;
|
|
|
|
|
2008-09-01 01:25:29 +02:00
|
|
|
#define test_state(s,ss) _test_state(__LINE__,s,ss)
|
|
|
|
static void _test_state(unsigned line, IActiveScript *script, SCRIPTSTATE exstate)
|
|
|
|
{
|
|
|
|
SCRIPTSTATE state = -1;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IActiveScript_GetScriptState(script, &state);
|
|
|
|
ok_(__FILE__,line) (hres == S_OK, "GetScriptState failed: %08x\n", hres);
|
|
|
|
ok_(__FILE__,line) (state == exstate, "state=%d, expected %d\n", state, exstate);
|
|
|
|
}
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
|
|
|
|
*ppv = iface;
|
|
|
|
IDispatch_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Dispatch_Release(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-03-24 17:49:58 +01:00
|
|
|
static ULONG global_named_item_ref, visible_named_item_ref, visible_code_named_item_ref, persistent_named_item_ref;
|
2020-03-05 17:12:03 +01:00
|
|
|
|
|
|
|
static ULONG WINAPI global_AddRef(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return ++global_named_item_ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI global_Release(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return --global_named_item_ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI visible_AddRef(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return ++visible_named_item_ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI visible_Release(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return --visible_named_item_ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI visible_code_AddRef(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return ++visible_code_named_item_ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI visible_code_Release(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return --visible_code_named_item_ref;
|
|
|
|
}
|
|
|
|
|
2020-03-24 17:49:58 +01:00
|
|
|
static ULONG WINAPI persistent_AddRef(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return ++persistent_named_item_ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI persistent_Release(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return --persistent_named_item_ref;
|
|
|
|
}
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
|
|
|
return DISP_E_BADINDEX;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt,
|
|
|
|
LCID lcid, DISPID *ids)
|
|
|
|
{
|
|
|
|
ok(name_cnt == 1, "name_cnt = %u\n", name_cnt);
|
|
|
|
if(!wcscmp(names[0], L"testCall")) {
|
|
|
|
*ids = 1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK_EXPECT2(GetIDsOfNames);
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
|
|
|
|
2020-03-27 18:34:08 +01:00
|
|
|
static HRESULT WINAPI visible_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt,
|
|
|
|
LCID lcid, DISPID *ids)
|
|
|
|
{
|
|
|
|
ok(name_cnt == 1, "name_cnt = %u\n", name_cnt);
|
|
|
|
if(!wcscmp(names[0], L"testCall")) {
|
|
|
|
*ids = 1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK_EXPECT2(GetIDsOfNames_visible);
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
|
|
|
|
2020-03-24 17:49:58 +01:00
|
|
|
static HRESULT WINAPI persistent_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt,
|
|
|
|
LCID lcid, DISPID *ids)
|
|
|
|
{
|
|
|
|
ok(name_cnt == 1, "name_cnt = %u\n", name_cnt);
|
|
|
|
|
|
|
|
CHECK_EXPECT2(GetIDsOfNames_persistent);
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID id, REFIID riid, LCID lcid, WORD flags,
|
|
|
|
DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, UINT *err)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(testCall);
|
|
|
|
ok(id == 1, "id = %u\n", id);
|
|
|
|
ok(flags == DISPATCH_METHOD, "flags = %x\n", flags);
|
|
|
|
ok(!dp->cArgs, "cArgs = %u\n", dp->cArgs);
|
|
|
|
ok(!res, "res = %p\n", res);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDispatchVtbl dispatch_vtbl = {
|
|
|
|
Dispatch_QueryInterface,
|
|
|
|
Dispatch_AddRef,
|
|
|
|
Dispatch_Release,
|
|
|
|
Dispatch_GetTypeInfoCount,
|
|
|
|
Dispatch_GetTypeInfo,
|
|
|
|
Dispatch_GetIDsOfNames,
|
|
|
|
Dispatch_Invoke
|
|
|
|
};
|
|
|
|
|
|
|
|
static IDispatch dispatch_object = { &dispatch_vtbl };
|
|
|
|
|
|
|
|
static const IDispatchVtbl global_named_item_vtbl = {
|
|
|
|
Dispatch_QueryInterface,
|
|
|
|
global_AddRef,
|
|
|
|
global_Release,
|
|
|
|
Dispatch_GetTypeInfoCount,
|
|
|
|
Dispatch_GetTypeInfo,
|
|
|
|
Dispatch_GetIDsOfNames,
|
|
|
|
Dispatch_Invoke
|
|
|
|
};
|
|
|
|
|
|
|
|
static IDispatch global_named_item = { &global_named_item_vtbl };
|
|
|
|
|
|
|
|
static const IDispatchVtbl visible_named_item_vtbl = {
|
|
|
|
Dispatch_QueryInterface,
|
|
|
|
visible_AddRef,
|
|
|
|
visible_Release,
|
|
|
|
Dispatch_GetTypeInfoCount,
|
|
|
|
Dispatch_GetTypeInfo,
|
2020-03-27 18:34:08 +01:00
|
|
|
visible_GetIDsOfNames,
|
2020-03-05 17:12:03 +01:00
|
|
|
Dispatch_Invoke
|
|
|
|
};
|
|
|
|
|
|
|
|
static IDispatch visible_named_item = { &visible_named_item_vtbl };
|
|
|
|
|
|
|
|
static const IDispatchVtbl visible_code_named_item_vtbl = {
|
|
|
|
Dispatch_QueryInterface,
|
|
|
|
visible_code_AddRef,
|
|
|
|
visible_code_Release,
|
|
|
|
Dispatch_GetTypeInfoCount,
|
|
|
|
Dispatch_GetTypeInfo,
|
|
|
|
Dispatch_GetIDsOfNames,
|
|
|
|
Dispatch_Invoke
|
|
|
|
};
|
|
|
|
|
|
|
|
static IDispatch visible_code_named_item = { &visible_code_named_item_vtbl };
|
|
|
|
|
2020-03-24 17:49:58 +01:00
|
|
|
static const IDispatchVtbl persistent_named_item_vtbl = {
|
|
|
|
Dispatch_QueryInterface,
|
|
|
|
persistent_AddRef,
|
|
|
|
persistent_Release,
|
|
|
|
Dispatch_GetTypeInfoCount,
|
|
|
|
Dispatch_GetTypeInfo,
|
|
|
|
persistent_GetIDsOfNames,
|
|
|
|
Dispatch_Invoke
|
|
|
|
};
|
|
|
|
|
|
|
|
static IDispatch persistent_named_item = { &persistent_named_item_vtbl };
|
|
|
|
|
2008-09-01 01:19:25 +02:00
|
|
|
static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
*ppv = iface;
|
|
|
|
else if(IsEqualGUID(&IID_IActiveScriptSite, riid))
|
|
|
|
*ppv = iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *plcid)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(GetLCID);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR pstrName,
|
|
|
|
DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti)
|
|
|
|
{
|
2020-03-05 17:12:03 +01:00
|
|
|
ok(dwReturnMask == SCRIPTINFO_IUNKNOWN, "dwReturnMask = %x\n", dwReturnMask);
|
|
|
|
if(!wcscmp(pstrName, L"globalItem")) {
|
|
|
|
CHECK_EXPECT(GetItemInfo_global);
|
|
|
|
IDispatch_AddRef(&global_named_item);
|
|
|
|
*ppiunkItem = (IUnknown*)&global_named_item;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if(!wcscmp(pstrName, L"globalCodeItem")) {
|
|
|
|
CHECK_EXPECT(GetItemInfo_global_code);
|
|
|
|
IDispatch_AddRef(&dispatch_object);
|
|
|
|
*ppiunkItem = (IUnknown*)&dispatch_object;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if(!wcscmp(pstrName, L"visibleItem")) {
|
|
|
|
CHECK_EXPECT(GetItemInfo_visible);
|
|
|
|
IDispatch_AddRef(&visible_named_item);
|
|
|
|
*ppiunkItem = (IUnknown*)&visible_named_item;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if(!wcscmp(pstrName, L"visibleCodeItem")) {
|
|
|
|
CHECK_EXPECT(GetItemInfo_visible_code);
|
|
|
|
IDispatch_AddRef(&visible_code_named_item);
|
|
|
|
*ppiunkItem = (IUnknown*)&visible_code_named_item;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2020-03-24 17:49:58 +01:00
|
|
|
if(!wcscmp(pstrName, L"persistent")) {
|
|
|
|
CHECK_EXPECT(GetItemInfo_persistent);
|
|
|
|
IDispatch_AddRef(&persistent_named_item);
|
|
|
|
*ppiunkItem = (IUnknown*)&persistent_named_item;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2020-03-05 17:12:03 +01:00
|
|
|
ok(0, "unexpected call %s\n", wine_dbgstr_w(pstrName));
|
2008-09-01 01:19:25 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface,
|
|
|
|
const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
|
|
|
|
{
|
|
|
|
switch(ssScriptState) {
|
2011-02-21 17:49:32 +01:00
|
|
|
case SCRIPTSTATE_UNINITIALIZED:
|
|
|
|
CHECK_EXPECT(OnStateChange_UNINITIALIZED);
|
|
|
|
return S_OK;
|
2008-09-01 01:19:25 +02:00
|
|
|
case SCRIPTSTATE_STARTED:
|
|
|
|
CHECK_EXPECT(OnStateChange_STARTED);
|
|
|
|
return S_OK;
|
2008-11-05 01:03:19 +01:00
|
|
|
case SCRIPTSTATE_CONNECTED:
|
|
|
|
CHECK_EXPECT(OnStateChange_CONNECTED);
|
|
|
|
return S_OK;
|
|
|
|
case SCRIPTSTATE_DISCONNECTED:
|
|
|
|
CHECK_EXPECT(OnStateChange_DISCONNECTED);
|
|
|
|
return S_OK;
|
2008-09-01 01:19:25 +02:00
|
|
|
case SCRIPTSTATE_CLOSED:
|
|
|
|
CHECK_EXPECT(OnStateChange_CLOSED);
|
|
|
|
return S_OK;
|
|
|
|
case SCRIPTSTATE_INITIALIZED:
|
|
|
|
CHECK_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
return S_OK;
|
|
|
|
default:
|
|
|
|
ok(0, "unexpected call %d\n", ssScriptState);
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
|
|
|
|
{
|
2020-03-05 17:12:03 +01:00
|
|
|
CHECK_EXPECT(OnScriptError);
|
|
|
|
return S_OK;
|
2008-09-01 01:19:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(OnEnterScript);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(OnLeaveScript);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = {
|
|
|
|
ActiveScriptSite_QueryInterface,
|
|
|
|
ActiveScriptSite_AddRef,
|
|
|
|
ActiveScriptSite_Release,
|
|
|
|
ActiveScriptSite_GetLCID,
|
|
|
|
ActiveScriptSite_GetItemInfo,
|
|
|
|
ActiveScriptSite_GetDocVersionString,
|
|
|
|
ActiveScriptSite_OnScriptTerminate,
|
|
|
|
ActiveScriptSite_OnStateChange,
|
|
|
|
ActiveScriptSite_OnScriptError,
|
|
|
|
ActiveScriptSite_OnEnterScript,
|
|
|
|
ActiveScriptSite_OnLeaveScript
|
|
|
|
};
|
|
|
|
|
|
|
|
static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl };
|
|
|
|
|
2009-12-30 19:49:45 +01:00
|
|
|
static void test_script_dispatch(IDispatchEx *dispex)
|
2008-09-01 01:23:38 +02:00
|
|
|
{
|
2009-12-30 19:49:45 +01:00
|
|
|
DISPPARAMS dp = {NULL,NULL,0,0};
|
|
|
|
EXCEPINFO ei;
|
2009-09-27 20:59:28 +02:00
|
|
|
BSTR str;
|
|
|
|
DISPID id;
|
2009-12-30 19:49:45 +01:00
|
|
|
VARIANT v;
|
2008-09-01 01:23:38 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2019-11-08 17:02:55 +01:00
|
|
|
str = SysAllocString(L"ActiveXObject");
|
2009-12-30 19:49:45 +01:00
|
|
|
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
|
|
|
|
SysFreeString(str);
|
|
|
|
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
2008-09-01 01:23:38 +02:00
|
|
|
|
2019-11-08 17:02:55 +01:00
|
|
|
str = SysAllocString(L"Math");
|
2009-12-30 19:49:45 +01:00
|
|
|
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
|
|
|
|
SysFreeString(str);
|
|
|
|
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
2008-09-01 01:23:38 +02:00
|
|
|
|
2009-12-30 19:49:45 +01:00
|
|
|
memset(&ei, 0, sizeof(ei));
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
|
|
|
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
ok(V_DISPATCH(&v) != NULL, "V_DISPATCH(v) = NULL\n");
|
|
|
|
VariantClear(&v);
|
2008-09-01 01:23:38 +02:00
|
|
|
|
2019-11-08 17:02:55 +01:00
|
|
|
str = SysAllocString(L"String");
|
2009-09-27 20:59:28 +02:00
|
|
|
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
|
|
|
|
SysFreeString(str);
|
|
|
|
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
|
|
|
|
2009-12-30 19:49:45 +01:00
|
|
|
memset(&ei, 0, sizeof(ei));
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
|
|
|
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
ok(V_DISPATCH(&v) != NULL, "V_DISPATCH(v) = NULL\n");
|
|
|
|
VariantClear(&v);
|
|
|
|
}
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
static IDispatchEx *get_script_dispatch(IActiveScript *script, const WCHAR *item_name)
|
2009-12-30 19:49:45 +01:00
|
|
|
{
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
IDispatch *disp;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
disp = (void*)0xdeadbeef;
|
2020-03-05 17:12:03 +01:00
|
|
|
hres = IActiveScript_GetScriptDispatch(script, item_name, &disp);
|
2009-12-30 19:49:45 +01:00
|
|
|
ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
|
|
|
|
|
2012-05-21 10:02:02 +02:00
|
|
|
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
|
2009-12-30 19:49:45 +01:00
|
|
|
IDispatch_Release(disp);
|
|
|
|
ok(hres == S_OK, "Could not get IDispatch iface: %08x\n", hres);
|
|
|
|
return dispex;
|
|
|
|
}
|
|
|
|
|
2019-12-12 13:54:03 +01:00
|
|
|
static void parse_script(IActiveScriptParse *parser, const WCHAR *src)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
|
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, src, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
}
|
|
|
|
|
2019-11-07 18:17:28 +01:00
|
|
|
#define get_disp_id(a,b,c,d) _get_disp_id(__LINE__,a,b,c,d)
|
2019-11-08 17:02:55 +01:00
|
|
|
static void _get_disp_id(unsigned line, IDispatchEx *dispex, const WCHAR *name, HRESULT exhr, DISPID *id)
|
2019-11-07 18:17:28 +01:00
|
|
|
{
|
|
|
|
DISPID id2;
|
|
|
|
HRESULT hr;
|
|
|
|
BSTR str;
|
|
|
|
|
2019-11-08 17:02:55 +01:00
|
|
|
str = SysAllocString(name);
|
2019-11-07 18:17:28 +01:00
|
|
|
hr = IDispatchEx_GetDispID(dispex, str, 0, id);
|
2019-11-08 17:02:55 +01:00
|
|
|
ok_(__FILE__,line)(hr == exhr, "GetDispID(%s) returned %08x, expected %08x\n",
|
|
|
|
wine_dbgstr_w(name), hr, exhr);
|
2019-11-07 18:17:28 +01:00
|
|
|
|
|
|
|
hr = IDispatchEx_GetIDsOfNames(dispex, &IID_NULL, &str, 1, 0, &id2);
|
|
|
|
SysFreeString(str);
|
2019-11-08 17:02:55 +01:00
|
|
|
ok_(__FILE__,line)(hr == exhr, "GetIDsOfNames(%s) returned %08x, expected %08x\n",
|
|
|
|
wine_dbgstr_w(name), hr, exhr);
|
|
|
|
ok_(__FILE__,line)(*id == id2, "GetIDsOfNames(%s) id != id2\n", wine_dbgstr_w(name));
|
2019-11-07 18:17:28 +01:00
|
|
|
}
|
|
|
|
|
2009-12-30 19:49:45 +01:00
|
|
|
static void test_no_script_dispatch(IActiveScript *script)
|
|
|
|
{
|
|
|
|
IDispatch *disp;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
disp = (void*)0xdeadbeef;
|
|
|
|
hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
|
|
|
|
ok(hres == E_UNEXPECTED, "hres = %08x, expected E_UNEXPECTED\n", hres);
|
|
|
|
ok(!disp, "disp != NULL\n");
|
2008-09-01 01:23:38 +02:00
|
|
|
}
|
|
|
|
|
2008-04-10 10:37:17 +02:00
|
|
|
static void test_safety(IUnknown *unk)
|
|
|
|
{
|
|
|
|
IObjectSafety *safety;
|
|
|
|
DWORD supported, enabled;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IObjectSafety, (void**)&safety);
|
|
|
|
ok(hres == S_OK, "Could not get IObjectSafety: %08x\n", hres);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, &supported, NULL);
|
|
|
|
ok(hres == E_POINTER, "GetInterfaceSafetyOptions failed: %08x, expected E_POINTER\n", hres);
|
|
|
|
hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, NULL, &enabled);
|
|
|
|
ok(hres == E_POINTER, "GetInterfaceSafetyOptions failed: %08x, expected E_POINTER\n", hres);
|
|
|
|
|
|
|
|
supported = enabled = 0xdeadbeef;
|
|
|
|
hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, &supported, &enabled);
|
|
|
|
ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
|
|
|
|
"supported=%x\n", supported);
|
|
|
|
ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
|
|
|
|
|
|
|
|
supported = enabled = 0xdeadbeef;
|
|
|
|
hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScript, &supported, &enabled);
|
|
|
|
ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
|
|
|
|
"supported=%x\n", supported);
|
|
|
|
ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
|
|
|
|
|
|
|
|
supported = enabled = 0xdeadbeef;
|
|
|
|
hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
|
|
|
|
ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
|
|
|
|
"supported=%x\n", supported);
|
|
|
|
ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
|
|
|
|
|
|
|
|
hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
|
|
|
|
INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER
|
|
|
|
|INTERFACESAFE_FOR_UNTRUSTED_CALLER,
|
|
|
|
INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER);
|
2008-04-14 01:02:13 +02:00
|
|
|
ok(hres == E_FAIL, "SetInterfaceSafetyOptions failed: %08x, expected E_FAIL\n", hres);
|
2008-04-10 10:37:17 +02:00
|
|
|
|
|
|
|
hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
|
|
|
|
INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER,
|
|
|
|
INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER);
|
|
|
|
ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
|
|
|
|
supported = enabled = 0xdeadbeef;
|
|
|
|
hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
|
|
|
|
ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
|
|
|
|
"supported=%x\n", supported);
|
|
|
|
ok(enabled == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
|
|
|
|
"enabled=%x\n", enabled);
|
|
|
|
|
2011-09-01 17:47:41 +02:00
|
|
|
hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, INTERFACESAFE_FOR_UNTRUSTED_DATA, 0);
|
|
|
|
ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
|
|
|
|
supported = enabled = 0xdeadbeef;
|
|
|
|
hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
|
|
|
|
ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
|
|
|
|
"supported=%x\n", supported);
|
|
|
|
ok(enabled == (INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER), "enabled=%x\n", enabled);
|
|
|
|
|
|
|
|
hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
|
|
|
|
INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER, 0);
|
|
|
|
ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
|
|
|
|
supported = enabled = 0xdeadbeef;
|
|
|
|
hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
|
|
|
|
ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
|
|
|
|
"supported=%x\n", supported);
|
|
|
|
ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
|
|
|
|
|
|
|
|
hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
|
|
|
|
INTERFACE_USES_DISPEX, 0);
|
|
|
|
ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
|
|
|
|
supported = enabled = 0xdeadbeef;
|
|
|
|
hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
|
|
|
|
ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
|
|
|
|
ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
|
|
|
|
"supported=%x\n", supported);
|
|
|
|
ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
|
|
|
|
|
2008-04-10 10:37:17 +02:00
|
|
|
IObjectSafety_Release(safety);
|
|
|
|
}
|
|
|
|
|
2009-10-19 20:39:24 +02:00
|
|
|
static HRESULT set_script_prop(IActiveScript *engine, DWORD property, VARIANT *val)
|
|
|
|
{
|
|
|
|
IActiveScriptProperty *script_prop;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptProperty,
|
|
|
|
(void**)&script_prop);
|
2010-09-21 15:58:48 +02:00
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptProperty: %08x\n", hres);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2009-10-19 20:39:24 +02:00
|
|
|
|
|
|
|
hres = IActiveScriptProperty_SetProperty(script_prop, property, NULL, val);
|
|
|
|
IActiveScriptProperty_Release(script_prop);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_invoke_versioning(IActiveScript *script)
|
|
|
|
{
|
|
|
|
VARIANT v;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
V_VT(&v) = VT_NULL;
|
|
|
|
hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
|
|
|
|
if(hres == E_NOTIMPL) {
|
|
|
|
win_skip("SCRIPTPROP_INVOKESTRING not supported\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_I2;
|
|
|
|
V_I2(&v) = 0;
|
|
|
|
hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
|
|
|
|
ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_I4;
|
|
|
|
V_I4(&v) = 16;
|
|
|
|
hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
|
|
|
|
ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_I4;
|
|
|
|
V_I4(&v) = 2;
|
|
|
|
hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
|
|
|
|
ok(hres == S_OK, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres);
|
|
|
|
}
|
|
|
|
|
2011-02-21 17:49:32 +01:00
|
|
|
static IActiveScript *create_jscript(void)
|
|
|
|
{
|
|
|
|
IActiveScript *ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2012-03-26 11:42:13 +02:00
|
|
|
hres = CoCreateInstance(engine_clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
2011-02-21 17:49:32 +01:00
|
|
|
&IID_IActiveScript, (void**)&ret);
|
|
|
|
ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-03-24 21:53:14 +01:00
|
|
|
static void test_jscript(void)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parse;
|
|
|
|
IActiveScript *script;
|
2009-12-30 19:49:45 +01:00
|
|
|
IDispatchEx *dispex;
|
2008-09-01 01:19:25 +02:00
|
|
|
ULONG ref;
|
2008-03-24 21:53:14 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
2011-02-21 17:49:32 +01:00
|
|
|
script = create_jscript();
|
2008-03-24 21:53:14 +01:00
|
|
|
|
2011-02-21 17:49:32 +01:00
|
|
|
hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
|
2008-03-24 21:53:14 +01:00
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
|
2008-09-01 01:25:29 +02:00
|
|
|
test_state(script, SCRIPTSTATE_UNINITIALIZED);
|
2011-02-21 17:49:32 +01:00
|
|
|
test_safety((IUnknown*)script);
|
2009-10-19 20:39:24 +02:00
|
|
|
test_invoke_versioning(script);
|
2008-04-10 10:37:17 +02:00
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_InitNew(parse);
|
2008-09-01 01:23:16 +02:00
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_InitNew(parse);
|
2008-09-01 01:23:16 +02:00
|
|
|
ok(hres == E_UNEXPECTED, "InitNew failed: %08x, expected E_UNEXPECTED\n", hres);
|
|
|
|
|
2008-09-01 01:19:25 +02:00
|
|
|
hres = IActiveScript_SetScriptSite(script, NULL);
|
|
|
|
ok(hres == E_POINTER, "SetScriptSite failed: %08x, expected E_POINTER\n", hres);
|
|
|
|
|
2008-09-01 01:25:29 +02:00
|
|
|
test_state(script, SCRIPTSTATE_UNINITIALIZED);
|
2009-12-30 19:49:45 +01:00
|
|
|
test_no_script_dispatch(script);
|
2008-09-01 01:23:38 +02:00
|
|
|
|
2008-09-01 01:19:25 +02:00
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
|
2008-09-01 01:25:29 +02:00
|
|
|
test_state(script, SCRIPTSTATE_INITIALIZED);
|
|
|
|
|
2008-09-01 01:19:25 +02:00
|
|
|
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres);
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
dispex = get_script_dispatch(script, NULL);
|
2009-12-30 19:49:45 +01:00
|
|
|
test_script_dispatch(dispex);
|
2008-09-01 01:23:38 +02:00
|
|
|
|
2008-09-05 02:38:17 +02:00
|
|
|
SET_EXPECT(OnStateChange_STARTED);
|
|
|
|
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(OnStateChange_STARTED);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_STARTED);
|
|
|
|
|
2008-09-01 01:19:25 +02:00
|
|
|
SET_EXPECT(OnStateChange_CLOSED);
|
|
|
|
hres = IActiveScript_Close(script);
|
|
|
|
ok(hres == S_OK, "Close failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(OnStateChange_CLOSED);
|
|
|
|
|
2008-09-01 01:25:29 +02:00
|
|
|
test_state(script, SCRIPTSTATE_CLOSED);
|
2009-12-30 19:49:45 +01:00
|
|
|
test_no_script_dispatch(script);
|
|
|
|
test_script_dispatch(dispex);
|
|
|
|
IDispatchEx_Release(dispex);
|
2008-09-01 01:23:38 +02:00
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
IActiveScriptParse_Release(parse);
|
2008-09-01 01:19:25 +02:00
|
|
|
|
2011-02-21 17:49:32 +01:00
|
|
|
ref = IActiveScript_Release(script);
|
2008-09-01 01:19:25 +02:00
|
|
|
ok(!ref, "ref = %d\n", ref);
|
2008-03-24 21:53:14 +01:00
|
|
|
}
|
|
|
|
|
2008-11-05 01:03:03 +01:00
|
|
|
static void test_jscript2(void)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parse;
|
|
|
|
IActiveScript *script;
|
|
|
|
ULONG ref;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2011-02-21 17:49:32 +01:00
|
|
|
script = create_jscript();
|
2008-11-05 01:03:03 +01:00
|
|
|
|
2011-02-21 17:49:32 +01:00
|
|
|
hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
|
2008-11-05 01:03:03 +01:00
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_InitNew(parse);
|
2008-11-05 01:03:03 +01:00
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_InitNew(parse);
|
2008-11-05 01:03:03 +01:00
|
|
|
ok(hres == E_UNEXPECTED, "InitNew failed: %08x, expected E_UNEXPECTED\n", hres);
|
|
|
|
|
2008-11-05 01:03:19 +01:00
|
|
|
SET_EXPECT(OnStateChange_CONNECTED);
|
|
|
|
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(OnStateChange_CONNECTED);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_DISCONNECTED);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
2008-11-05 01:03:03 +01:00
|
|
|
SET_EXPECT(OnStateChange_CLOSED);
|
|
|
|
hres = IActiveScript_Close(script);
|
|
|
|
ok(hres == S_OK, "Close failed: %08x\n", hres);
|
2008-11-05 01:03:19 +01:00
|
|
|
CHECK_CALLED(OnStateChange_DISCONNECTED);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
2008-11-05 01:03:03 +01:00
|
|
|
CHECK_CALLED(OnStateChange_CLOSED);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_CLOSED);
|
2009-12-30 19:49:45 +01:00
|
|
|
test_no_script_dispatch(script);
|
2008-11-05 01:03:03 +01:00
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
IActiveScriptParse_Release(parse);
|
2008-11-05 01:03:03 +01:00
|
|
|
|
2011-02-21 17:49:32 +01:00
|
|
|
ref = IActiveScript_Release(script);
|
|
|
|
ok(!ref, "ref = %d\n", ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_jscript_uninitializing(void)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parse;
|
|
|
|
IActiveScript *script;
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
ULONG ref;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
script = create_jscript();
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_InitNew(parse);
|
2011-02-21 17:49:32 +01:00
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_INITIALIZED);
|
|
|
|
|
2020-12-06 16:02:19 +01:00
|
|
|
hres = IActiveScriptParse_ParseScriptText(parse, L"function f() {}", NULL, NULL, NULL, 0, 1, 0x42, NULL, NULL);
|
2011-02-21 17:49:32 +01:00
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_UNINITIALIZED);
|
|
|
|
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(OnStateChange_UNINITIALIZED);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_CONNECTED);
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(OnStateChange_CONNECTED);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
dispex = get_script_dispatch(script, NULL);
|
2011-02-21 17:49:32 +01:00
|
|
|
ok(dispex != NULL, "dispex == NULL\n");
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_DISCONNECTED);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
SET_EXPECT(OnStateChange_UNINITIALIZED);
|
|
|
|
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(OnStateChange_DISCONNECTED);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
CHECK_CALLED(OnStateChange_UNINITIALIZED);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
|
|
|
|
hres = IActiveScript_Close(script);
|
|
|
|
ok(hres == S_OK, "Close failed: %08x\n", hres);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_CLOSED);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
ok(hres == E_UNEXPECTED, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x, expected E_UNEXPECTED\n", hres);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_CLOSED);
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
IActiveScriptParse_Release(parse);
|
2011-02-21 17:49:32 +01:00
|
|
|
|
|
|
|
ref = IActiveScript_Release(script);
|
2008-11-05 01:03:03 +01:00
|
|
|
ok(!ref, "ref = %d\n", ref);
|
|
|
|
}
|
|
|
|
|
2011-07-18 18:05:13 +02:00
|
|
|
static void test_aggregation(void)
|
|
|
|
{
|
|
|
|
IUnknown *unk = (IUnknown*)0xdeadbeef;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_JScript, (IUnknown*)0xdeadbeef, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
|
|
|
&IID_IUnknown, (void**)&unk);
|
2016-09-08 19:16:51 +02:00
|
|
|
ok(hres == CLASS_E_NOAGGREGATION,
|
2011-07-18 18:05:13 +02:00
|
|
|
"CoCreateInstance failed: %08x, expected CLASS_E_NOAGGREGATION\n", hres);
|
2012-01-12 13:48:00 +01:00
|
|
|
ok(!unk || broken(unk != NULL), "unk = %p\n", unk);
|
2011-07-18 18:05:13 +02:00
|
|
|
}
|
|
|
|
|
2019-11-07 18:17:28 +01:00
|
|
|
static void test_code_persistence(void)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parse;
|
|
|
|
IActiveScript *script;
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
DISPID id;
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
script = create_jscript();
|
|
|
|
|
|
|
|
hr = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
|
|
|
|
ok(hr == S_OK, "Could not get IActiveScriptParse iface: %08x\n", hr);
|
|
|
|
test_state(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
test_safety((IUnknown*)script);
|
|
|
|
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
hr = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hr == S_OK, "SetScriptSite failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
hr = IActiveScriptParse_InitNew(parse);
|
|
|
|
ok(hr == S_OK, "InitNew failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
test_state(script, SCRIPTSTATE_INITIALIZED);
|
|
|
|
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse,
|
|
|
|
L"var x = 1;\n"
|
|
|
|
L"var y = 2;\n",
|
|
|
|
NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse,
|
|
|
|
L"var z = 3;\n"
|
|
|
|
L"var y = 42;\n"
|
|
|
|
L"var v = 10;\n",
|
|
|
|
NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISPERSISTENT, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
|
|
|
|
/* Pending code does not add identifiers to the global scope */
|
2020-03-05 17:12:03 +01:00
|
|
|
dispex = get_script_dispatch(script, NULL);
|
2019-11-07 18:17:28 +01:00
|
|
|
id = 0;
|
2019-11-08 17:02:55 +01:00
|
|
|
get_disp_id(dispex, L"x", DISP_E_UNKNOWNNAME, &id);
|
2019-11-07 18:17:28 +01:00
|
|
|
ok(id == -1, "id = %d, expected -1\n", id);
|
|
|
|
id = 0;
|
2019-11-08 17:02:55 +01:00
|
|
|
get_disp_id(dispex, L"y", DISP_E_UNKNOWNNAME, &id);
|
2019-11-07 18:17:28 +01:00
|
|
|
ok(id == -1, "id = %d, expected -1\n", id);
|
|
|
|
id = 0;
|
2019-11-08 17:02:55 +01:00
|
|
|
get_disp_id(dispex, L"z", DISP_E_UNKNOWNNAME, &id);
|
2019-11-07 18:17:28 +01:00
|
|
|
ok(id == -1, "id = %d, expected -1\n", id);
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
|
|
|
/* Uninitialized state removes code without SCRIPTTEXT_ISPERSISTENT */
|
|
|
|
SET_EXPECT(OnStateChange_UNINITIALIZED);
|
|
|
|
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_UNINITIALIZED);
|
|
|
|
test_no_script_dispatch(script);
|
|
|
|
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
hr = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hr == S_OK, "SetScriptSite failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"v = 20;\n", NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_CONNECTED);
|
|
|
|
SET_EXPECT_MULTI(OnEnterScript, 2);
|
|
|
|
SET_EXPECT_MULTI(OnLeaveScript, 2);
|
|
|
|
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_CONNECTED);
|
|
|
|
CHECK_CALLED_MULTI(OnEnterScript, 2);
|
|
|
|
CHECK_CALLED_MULTI(OnLeaveScript, 2);
|
|
|
|
test_state(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
dispex = get_script_dispatch(script, NULL);
|
2019-11-07 18:17:28 +01:00
|
|
|
id = 0;
|
2019-11-08 17:02:55 +01:00
|
|
|
get_disp_id(dispex, L"x", DISP_E_UNKNOWNNAME, &id);
|
2019-11-07 18:17:28 +01:00
|
|
|
ok(id == -1, "id = %d, expected -1\n", id);
|
|
|
|
id = 0;
|
2019-11-08 17:02:55 +01:00
|
|
|
get_disp_id(dispex, L"y", S_OK, &id);
|
2019-11-07 18:17:28 +01:00
|
|
|
ok(id != -1, "id = -1\n");
|
|
|
|
id = 0;
|
2019-11-08 17:02:55 +01:00
|
|
|
get_disp_id(dispex, L"z", S_OK, &id);
|
2019-11-07 18:17:28 +01:00
|
|
|
ok(id != -1, "id = -1\n");
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"y", NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_I4 && V_I2(&var) == 42, "V_VT(y) = %d, V_I2(y) = %d\n", V_VT(&var), V_I2(&var));
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"v", NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_I4 && V_I2(&var) == 20, "V_VT(var) = %d, V_I2(var) = %d\n", V_VT(&var), V_I2(&var));
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
/* Uninitialized state does not remove persistent code, even if it was executed */
|
|
|
|
SET_EXPECT(OnStateChange_DISCONNECTED);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
SET_EXPECT(OnStateChange_UNINITIALIZED);
|
|
|
|
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_DISCONNECTED);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
CHECK_CALLED(OnStateChange_UNINITIALIZED);
|
|
|
|
test_no_script_dispatch(script);
|
|
|
|
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
hr = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hr == S_OK, "SetScriptSite failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
dispex = get_script_dispatch(script, NULL);
|
2019-11-07 18:17:28 +01:00
|
|
|
id = 0;
|
2019-11-08 17:02:55 +01:00
|
|
|
get_disp_id(dispex, L"z", DISP_E_UNKNOWNNAME, &id);
|
2019-11-07 18:17:28 +01:00
|
|
|
ok(id == -1, "id = %d, expected -1\n", id);
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_CONNECTED);
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_CONNECTED);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
test_state(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
dispex = get_script_dispatch(script, NULL);
|
2019-11-07 18:17:28 +01:00
|
|
|
id = 0;
|
2019-11-08 17:02:55 +01:00
|
|
|
get_disp_id(dispex, L"z", S_OK, &id);
|
2019-11-07 18:17:28 +01:00
|
|
|
ok(id != -1, "id = -1\n");
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"y", NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_I4 && V_I2(&var) == 42, "V_VT(y) = %d, V_I2(y) = %d\n", V_VT(&var), V_I2(&var));
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"v", NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_I4 && V_I2(&var) == 10, "V_VT(var) = %d, V_I2(var) = %d\n", V_VT(&var), V_I2(&var));
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_DISCONNECTED);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
SET_EXPECT(OnStateChange_UNINITIALIZED);
|
|
|
|
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_DISCONNECTED);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
CHECK_CALLED(OnStateChange_UNINITIALIZED);
|
|
|
|
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
hr = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hr == S_OK, "SetScriptSite failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"y = 2;\n", NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISPERSISTENT, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
|
|
|
|
/* Closing the script engine removes all code (even if it's pending and persistent) */
|
|
|
|
SET_EXPECT(OnStateChange_CLOSED);
|
|
|
|
hr = IActiveScript_Close(script);
|
|
|
|
ok(hr == S_OK, "Close failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_CLOSED);
|
|
|
|
test_state(script, SCRIPTSTATE_CLOSED);
|
|
|
|
test_no_script_dispatch(script);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
hr = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hr == S_OK, "SetScriptSite failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
test_state(script, SCRIPTSTATE_INITIALIZED);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_CONNECTED);
|
|
|
|
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_CONNECTED);
|
|
|
|
test_state(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
dispex = get_script_dispatch(script, NULL);
|
2019-11-07 18:17:28 +01:00
|
|
|
id = 0;
|
2019-11-08 17:02:55 +01:00
|
|
|
get_disp_id(dispex, L"y", DISP_E_UNKNOWNNAME, &id);
|
2019-11-07 18:17:28 +01:00
|
|
|
ok(id == -1, "id = %d, expected -1\n", id);
|
|
|
|
id = 0;
|
2019-11-08 17:02:55 +01:00
|
|
|
get_disp_id(dispex, L"z", DISP_E_UNKNOWNNAME, &id);
|
2019-11-07 18:17:28 +01:00
|
|
|
ok(id == -1, "id = %d, expected -1\n", id);
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
|
|
|
IActiveScriptParse_Release(parse);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_DISCONNECTED);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
SET_EXPECT(OnStateChange_CLOSED);
|
|
|
|
ref = IActiveScript_Release(script);
|
|
|
|
ok(!ref, "ref = %d\n", ref);
|
|
|
|
CHECK_CALLED(OnStateChange_DISCONNECTED);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
CHECK_CALLED(OnStateChange_CLOSED);
|
|
|
|
}
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
static void test_named_items(void)
|
|
|
|
{
|
|
|
|
static const WCHAR *global_idents[] =
|
|
|
|
{
|
|
|
|
L"ActiveXObject",
|
|
|
|
L"Array",
|
|
|
|
L"Boolean",
|
|
|
|
L"ReferenceError",
|
|
|
|
L"RegExp",
|
|
|
|
L"decodeURI",
|
|
|
|
L"isNaN",
|
|
|
|
|
|
|
|
L"global_this",
|
|
|
|
L"globalCode_this",
|
|
|
|
L"testFunc_global",
|
|
|
|
L"testVar_global"
|
|
|
|
};
|
|
|
|
static const WCHAR *global_code_test[] =
|
|
|
|
{
|
|
|
|
L"testFunc_global();",
|
|
|
|
L"if(testVar_global != 5) throw new Error();",
|
|
|
|
L"var testObj = new testClassFunc();",
|
|
|
|
L"eval(\"testFunc_global();\");",
|
|
|
|
L"if(Math.abs(-17) != 17) throw new Error();"
|
|
|
|
};
|
|
|
|
static const WCHAR *context_idents[] =
|
|
|
|
{
|
|
|
|
L"testFunc",
|
2020-03-07 14:40:38 +01:00
|
|
|
L"testVar",
|
|
|
|
L"testFuncConstr"
|
2020-03-05 17:12:03 +01:00
|
|
|
};
|
|
|
|
static const WCHAR *context_code_test[] =
|
|
|
|
{
|
|
|
|
L"testFunc();",
|
|
|
|
L"if(testVar != 42) throw new Error();",
|
2020-03-07 14:40:38 +01:00
|
|
|
L"if(Math.abs(-testVar) != 42) throw new Error();",
|
|
|
|
L"if(testFuncConstr() != testVar) throw new Error();"
|
2020-03-05 17:12:03 +01:00
|
|
|
};
|
|
|
|
IDispatchEx *dispex, *dispex2;
|
|
|
|
IActiveScriptParse *parse;
|
|
|
|
IActiveScript *script;
|
|
|
|
IDispatch *disp;
|
|
|
|
VARIANT var;
|
|
|
|
unsigned i;
|
|
|
|
HRESULT hr;
|
|
|
|
DISPID id;
|
|
|
|
ULONG ref;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
script = create_jscript();
|
|
|
|
|
|
|
|
hr = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
|
|
|
|
ok(hr == S_OK, "Could not get IActiveScriptParse: %08x\n", hr);
|
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
|
|
|
|
hr = IActiveScript_AddNamedItem(script, L"visibleItem", SCRIPTITEM_ISVISIBLE);
|
|
|
|
ok(hr == E_UNEXPECTED, "AddNamedItem returned: %08x\n", hr);
|
|
|
|
hr = IActiveScript_AddNamedItem(script, L"globalItem", SCRIPTITEM_GLOBALMEMBERS);
|
|
|
|
ok(hr == E_UNEXPECTED, "AddNamedItem returned: %08x\n", hr);
|
|
|
|
hr = IActiveScript_AddNamedItem(script, L"codeOnlyItem", SCRIPTITEM_CODEONLY);
|
|
|
|
ok(hr == E_UNEXPECTED, "AddNamedItem returned: %08x\n", hr);
|
2020-03-24 17:49:58 +01:00
|
|
|
hr = IActiveScript_AddNamedItem(script, L"persistent", SCRIPTITEM_ISPERSISTENT | SCRIPTITEM_CODEONLY);
|
|
|
|
ok(hr == E_UNEXPECTED, "AddNamedItem returned: %08x\n", hr);
|
2020-03-05 17:12:03 +01:00
|
|
|
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
hr = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hr == S_OK, "SetScriptSite failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
|
|
|
|
SET_EXPECT(GetItemInfo_global);
|
|
|
|
hr = IActiveScript_AddNamedItem(script, L"globalItem", SCRIPTITEM_GLOBALMEMBERS);
|
|
|
|
ok(hr == S_OK, "AddNamedItem failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(GetItemInfo_global);
|
|
|
|
|
|
|
|
hr = IActiveScript_AddNamedItem(script, L"visibleItem", SCRIPTITEM_ISVISIBLE);
|
|
|
|
ok(hr == S_OK, "AddNamedItem failed: %08x\n", hr);
|
|
|
|
hr = IActiveScript_AddNamedItem(script, L"visibleCodeItem", SCRIPTITEM_ISVISIBLE | SCRIPTITEM_CODEONLY);
|
|
|
|
ok(hr == S_OK, "AddNamedItem failed: %08x\n", hr);
|
|
|
|
hr = IActiveScript_AddNamedItem(script, L"codeOnlyItem", SCRIPTITEM_CODEONLY);
|
|
|
|
ok(hr == S_OK, "AddNamedItem failed: %08x\n", hr);
|
2020-03-24 17:49:58 +01:00
|
|
|
hr = IActiveScript_AddNamedItem(script, L"persistent", SCRIPTITEM_ISPERSISTENT | SCRIPTITEM_CODEONLY);
|
|
|
|
ok(hr == S_OK, "AddNamedItem failed: %08x\n", hr);
|
2020-03-05 17:12:03 +01:00
|
|
|
|
|
|
|
ok(global_named_item_ref > 0, "global_named_item_ref = %u\n", global_named_item_ref);
|
|
|
|
ok(visible_named_item_ref == 0, "visible_named_item_ref = %u\n", visible_named_item_ref);
|
|
|
|
ok(visible_code_named_item_ref == 0, "visible_code_named_item_ref = %u\n", visible_code_named_item_ref);
|
2020-03-24 17:49:58 +01:00
|
|
|
ok(persistent_named_item_ref == 0, "persistent_named_item_ref = %u\n", persistent_named_item_ref);
|
2020-03-05 17:12:03 +01:00
|
|
|
|
2020-03-07 14:40:33 +01:00
|
|
|
hr = IActiveScript_GetScriptDispatch(script, L"noContext", &disp);
|
|
|
|
ok(hr == E_INVALIDARG, "GetScriptDispatch returned: %08x\n", hr);
|
|
|
|
hr = IActiveScript_GetScriptDispatch(script, L"codeONLYItem", &disp);
|
|
|
|
ok(hr == E_INVALIDARG, "GetScriptDispatch returned: %08x\n", hr);
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
SET_EXPECT(GetItemInfo_global_code);
|
|
|
|
hr = IActiveScript_AddNamedItem(script, L"globalCodeItem", SCRIPTITEM_GLOBALMEMBERS | SCRIPTITEM_CODEONLY);
|
|
|
|
ok(hr == S_OK, "AddNamedItem failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(GetItemInfo_global_code);
|
|
|
|
|
|
|
|
dispex = get_script_dispatch(script, NULL);
|
|
|
|
dispex2 = get_script_dispatch(script, L"globalItem");
|
|
|
|
ok(dispex == dispex2, "get_script_dispatch returned different dispatch objects.\n");
|
|
|
|
IDispatchEx_Release(dispex2);
|
|
|
|
dispex2 = get_script_dispatch(script, L"globalCodeItem");
|
|
|
|
ok(dispex == dispex2, "get_script_dispatch returned different dispatch objects.\n");
|
|
|
|
IDispatchEx_Release(dispex2);
|
|
|
|
dispex2 = get_script_dispatch(script, L"codeOnlyItem");
|
|
|
|
ok(dispex != dispex2, "get_script_dispatch returned same dispatch objects.\n");
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
hr = IActiveScriptParse_InitNew(parse);
|
|
|
|
ok(hr == S_OK, "InitNew failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_CONNECTED);
|
|
|
|
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_CONNECTED);
|
|
|
|
|
|
|
|
SET_EXPECT(testCall);
|
|
|
|
parse_script(parse, L"testCall();");
|
|
|
|
CHECK_CALLED(testCall);
|
|
|
|
|
|
|
|
SET_EXPECT(GetItemInfo_visible);
|
|
|
|
SET_EXPECT(testCall);
|
|
|
|
parse_script(parse, L"visibleItem.testCall();");
|
|
|
|
CHECK_CALLED(GetItemInfo_visible);
|
|
|
|
CHECK_CALLED(testCall);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
SET_EXPECT(testCall);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"testCall();", L"visibleCodeItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
CHECK_CALLED(testCall);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(GetIDsOfNames);
|
|
|
|
SET_EXPECT(OnScriptError);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"codeOnlyItem();", L"codeOnlyItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(FAILED(hr), "ParseScriptText returned: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(GetIDsOfNames);
|
|
|
|
CHECK_CALLED(OnScriptError);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
hr = IActiveScript_GetScriptDispatch(script, L"visibleCodeItem", &disp);
|
|
|
|
ok(hr == S_OK, "GetScriptDispatch returned: %08x\n", hr);
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"this", L"visibleCodeItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == disp,
|
|
|
|
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
|
|
|
|
VariantClear(&var);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
IDispatch_Release(disp);
|
|
|
|
|
|
|
|
SET_EXPECT(GetItemInfo_visible_code);
|
|
|
|
SET_EXPECT(testCall);
|
|
|
|
parse_script(parse, L"visibleCodeItem.testCall();");
|
|
|
|
CHECK_CALLED(GetItemInfo_visible_code);
|
|
|
|
CHECK_CALLED(testCall);
|
|
|
|
|
|
|
|
ok(global_named_item_ref > 0, "global_named_item_ref = %u\n", global_named_item_ref);
|
|
|
|
ok(visible_named_item_ref > 0, "visible_named_item_ref = %u\n", visible_named_item_ref);
|
|
|
|
ok(visible_code_named_item_ref > 0, "visible_code_named_item_ref = %u\n", visible_code_named_item_ref);
|
2020-03-24 17:49:58 +01:00
|
|
|
ok(persistent_named_item_ref == 0, "persistent_named_item_ref = %u\n", persistent_named_item_ref);
|
2020-03-05 17:12:03 +01:00
|
|
|
|
|
|
|
SET_EXPECT(testCall);
|
|
|
|
parse_script(parse, L"visibleItem.testCall();");
|
|
|
|
CHECK_CALLED(testCall);
|
|
|
|
|
2020-03-07 14:40:31 +01:00
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"function testFunc() { }", L"CodeOnlyItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ParseScriptText returned: %08x\n", hr);
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(GetIDsOfNames);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L""
|
|
|
|
"var global_this = 0;\n"
|
|
|
|
"var globalCode_this = 0;\n"
|
|
|
|
"function testFunc_global() { }\n"
|
|
|
|
"var testVar_global = 10;\n"
|
|
|
|
"function testClassFunc() { this.x = 10; }\n",
|
|
|
|
NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISPERSISTENT, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(GetIDsOfNames);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"function testFunc() { }\n", L"codeOnlyItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L""
|
|
|
|
"var testVar = 42;\n"
|
2020-03-07 14:40:38 +01:00
|
|
|
"testVar_global = 5;\n"
|
|
|
|
"var testFuncConstr = new Function(\"return testVar;\");\n",
|
2020-03-05 17:12:03 +01:00
|
|
|
L"codeOnlyItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISPERSISTENT, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
2020-03-27 18:34:08 +01:00
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(GetIDsOfNames_visible);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"var abc;\n", L"visibleItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(GetIDsOfNames_visible);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"abc = 5;\n", L"visibleItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(GetIDsOfNames_visible);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"testVar_global = 5;\n", L"visibleItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(GetIDsOfNames_visible);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"var abc; testVar_global = 5;\n", L"visibleCodeItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"global_this = this;\n", L"globalItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISPERSISTENT, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"globalCode_this = this;\n", L"globalCodeItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISPERSISTENT, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(global_idents); i++)
|
|
|
|
{
|
|
|
|
bstr = SysAllocString(global_idents[i]);
|
|
|
|
id = 0;
|
|
|
|
hr = IDispatchEx_GetDispID(dispex, bstr, 0, &id);
|
|
|
|
ok(hr == S_OK, "GetDispID(%s) returned %08x\n", wine_dbgstr_w(global_idents[i]), hr);
|
|
|
|
ok(id != -1, "[%s] id = -1\n", wine_dbgstr_w(global_idents[i]));
|
|
|
|
|
|
|
|
id = 0;
|
|
|
|
hr = IDispatchEx_GetDispID(dispex2, bstr, 0, &id);
|
|
|
|
ok(hr == DISP_E_UNKNOWNNAME, "GetDispID(%s) returned %08x\n", wine_dbgstr_w(global_idents[i]), hr);
|
|
|
|
ok(id == -1, "[%s] id = %d, expected -1\n", wine_dbgstr_w(global_idents[i]), id);
|
|
|
|
SysFreeString(bstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(context_idents); i++)
|
|
|
|
{
|
|
|
|
bstr = SysAllocString(context_idents[i]);
|
|
|
|
id = 0;
|
|
|
|
hr = IDispatchEx_GetDispID(dispex, bstr, 0, &id);
|
|
|
|
ok(hr == DISP_E_UNKNOWNNAME, "GetDispID(%s) returned %08x\n", wine_dbgstr_w(context_idents[i]), hr);
|
|
|
|
ok(id == -1, "[%s] id = %d, expected -1\n", wine_dbgstr_w(context_idents[i]), id);
|
|
|
|
id = 0;
|
|
|
|
hr = IDispatchEx_GetDispID(dispex2, bstr, 0, &id);
|
|
|
|
ok(hr == S_OK, "GetDispID(%s) returned %08x\n", wine_dbgstr_w(context_idents[i]), hr);
|
|
|
|
ok(id != -1, "[%s] id = -1\n", wine_dbgstr_w(context_idents[i]));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(global_code_test); i++)
|
|
|
|
{
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, global_code_test[i], NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText(%s) failed: %08x\n", wine_dbgstr_w(global_code_test[i]), hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(GetIDsOfNames);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, global_code_test[i], L"codeOnlyItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText(%s) failed: %08x\n", wine_dbgstr_w(global_code_test[i]), hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(context_code_test); i++)
|
|
|
|
{
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(GetIDsOfNames);
|
|
|
|
SET_EXPECT(OnScriptError);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, context_code_test[i], NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(FAILED(hr), "ParseScriptText(%s) returned: %08x\n", wine_dbgstr_w(context_code_test[i]), hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(GetIDsOfNames);
|
|
|
|
CHECK_CALLED(OnScriptError);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, context_code_test[i], L"codeOnlyItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText(%s) failed: %08x\n", wine_dbgstr_w(context_code_test[i]), hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"this", NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == &global_named_item,
|
|
|
|
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
|
|
|
|
VariantClear(&var);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"this", L"visibleItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == &visible_named_item,
|
|
|
|
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
|
|
|
|
VariantClear(&var);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"this", L"codeOnlyItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == (IDispatch*)dispex2,
|
|
|
|
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
|
|
|
|
VariantClear(&var);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"globalCode_this", NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == &global_named_item,
|
|
|
|
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
|
|
|
|
VariantClear(&var);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
IDispatchEx_Release(dispex2);
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
2020-03-27 18:34:08 +01:00
|
|
|
dispex = get_script_dispatch(script, L"persistent");
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"this", L"persistent", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == (IDispatch*)dispex,
|
|
|
|
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
|
|
|
|
VariantClear(&var);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
2020-03-24 17:49:58 +01:00
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"var x = 13;\n", L"persistent", NULL, NULL, 0, 0, SCRIPTTEXT_ISPERSISTENT, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"x = 10;\n", L"persistent", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"x", L"persistent", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_I4 && V_I4(&var) == 10, "Unexpected 'x': V_VT = %d, V_I4 = %d\n", V_VT(&var), V_I4(&var));
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
dispex = get_script_dispatch(script, L"persistent");
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
/* reinitialize script engine */
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_DISCONNECTED);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
SET_EXPECT(OnStateChange_UNINITIALIZED);
|
|
|
|
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_DISCONNECTED);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
CHECK_CALLED(OnStateChange_UNINITIALIZED);
|
|
|
|
test_no_script_dispatch(script);
|
|
|
|
|
|
|
|
ok(global_named_item_ref == 0, "global_named_item_ref = %u\n", global_named_item_ref);
|
|
|
|
ok(visible_named_item_ref == 0, "visible_named_item_ref = %u\n", visible_named_item_ref);
|
|
|
|
ok(visible_code_named_item_ref == 0, "visible_code_named_item_ref = %u\n", visible_code_named_item_ref);
|
2020-03-24 17:49:58 +01:00
|
|
|
ok(persistent_named_item_ref == 0, "persistent_named_item_ref = %u\n", persistent_named_item_ref);
|
2020-03-05 17:12:03 +01:00
|
|
|
|
|
|
|
hr = IActiveScript_GetScriptDispatch(script, L"codeOnlyItem", &disp);
|
|
|
|
ok(hr == E_UNEXPECTED, "hr = %08x, expected E_UNEXPECTED\n", hr);
|
|
|
|
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
2020-03-24 17:49:58 +01:00
|
|
|
SET_EXPECT(GetItemInfo_persistent);
|
2020-03-05 17:12:03 +01:00
|
|
|
hr = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hr == S_OK, "SetScriptSite failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
2020-03-24 17:49:58 +01:00
|
|
|
CHECK_CALLED(GetItemInfo_persistent);
|
|
|
|
ok(persistent_named_item_ref > 0, "persistent_named_item_ref = %u\n", persistent_named_item_ref);
|
2020-03-05 17:12:03 +01:00
|
|
|
|
|
|
|
hr = IActiveScript_AddNamedItem(script, L"codeOnlyItem", SCRIPTITEM_CODEONLY);
|
|
|
|
ok(hr == S_OK, "AddNamedItem failed: %08x\n", hr);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_CONNECTED);
|
2020-03-24 17:49:58 +01:00
|
|
|
SET_EXPECT_MULTI(OnEnterScript, 5);
|
|
|
|
SET_EXPECT_MULTI(OnLeaveScript, 5);
|
|
|
|
SET_EXPECT(GetIDsOfNames_persistent);
|
2020-03-05 17:12:03 +01:00
|
|
|
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_CONNECTED);
|
2020-03-24 17:49:58 +01:00
|
|
|
CHECK_CALLED_MULTI(OnEnterScript, 5);
|
|
|
|
CHECK_CALLED_MULTI(OnLeaveScript, 5);
|
2020-03-27 18:34:56 +01:00
|
|
|
CHECK_CALLED(GetIDsOfNames_persistent);
|
2020-03-05 17:12:03 +01:00
|
|
|
test_state(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
|
2020-03-24 17:49:58 +01:00
|
|
|
dispex2 = get_script_dispatch(script, L"persistent");
|
|
|
|
ok(dispex != dispex2, "Same script dispatch returned for \"persistent\" named item\n");
|
|
|
|
IDispatchEx_Release(dispex2);
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"x", L"persistent", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_I4 && V_I4(&var) == 13, "Unexpected 'x': V_VT = %d, V_I4 = %d\n", V_VT(&var), V_I4(&var));
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
2020-03-27 18:34:08 +01:00
|
|
|
/* this object it set to named idem when persistent items are re-initialized, even for CODEONLY items */
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"this", L"persistent", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == &persistent_named_item,
|
|
|
|
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
|
|
|
|
VariantClear(&var);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
/* lookups also query named items */
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
SET_EXPECT(GetIDsOfNames_persistent);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"var abc123;", L"persistent", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
CHECK_CALLED(GetIDsOfNames_persistent);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
SET_EXPECT(GetIDsOfNames_persistent);
|
|
|
|
SET_EXPECT(OnScriptError);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"testCall();", L"persistent", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(FAILED(hr), "ParseScriptText returned: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
CHECK_CALLED(GetIDsOfNames_persistent);
|
|
|
|
CHECK_CALLED(OnScriptError);
|
|
|
|
|
2020-03-05 17:12:03 +01:00
|
|
|
dispex = get_script_dispatch(script, NULL);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(global_idents); i++)
|
|
|
|
{
|
|
|
|
bstr = SysAllocString(global_idents[i]);
|
|
|
|
id = 0;
|
|
|
|
hr = IDispatchEx_GetDispID(dispex, bstr, 0, &id);
|
|
|
|
ok(hr == S_OK, "GetDispID(%s) returned %08x\n", wine_dbgstr_w(global_idents[i]), hr);
|
|
|
|
ok(id != -1, "[%s] id = -1\n", wine_dbgstr_w(global_idents[i]));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(context_idents); i++)
|
|
|
|
{
|
|
|
|
bstr = SysAllocString(context_idents[i]);
|
|
|
|
id = 0;
|
|
|
|
hr = IDispatchEx_GetDispID(dispex, bstr, 0, &id);
|
|
|
|
ok(hr == DISP_E_UNKNOWNNAME, "GetDispID(%s) returned %08x\n", wine_dbgstr_w(context_idents[i]), hr);
|
|
|
|
ok(id == -1, "[%s] id = %d, expected -1\n", wine_dbgstr_w(context_idents[i]), id);
|
|
|
|
SysFreeString(bstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"global_this", NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == (IDispatch*)dispex,
|
|
|
|
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
|
|
|
|
VariantClear(&var);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"globalCode_this", NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == (IDispatch*)dispex,
|
|
|
|
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
|
|
|
|
VariantClear(&var);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, L"global_this = 0; globalCode_this = 0;\n", NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
|
|
|
dispex = get_script_dispatch(script, L"codeOnlyItem");
|
|
|
|
for (i = 0; i < ARRAY_SIZE(global_idents); i++)
|
|
|
|
{
|
|
|
|
bstr = SysAllocString(global_idents[i]);
|
|
|
|
id = 0;
|
|
|
|
hr = IDispatchEx_GetDispID(dispex, bstr, 0, &id);
|
|
|
|
ok(hr == DISP_E_UNKNOWNNAME, "GetDispID(%s) returned %08x\n", wine_dbgstr_w(global_idents[i]), hr);
|
|
|
|
ok(id == -1, "[%s] id = %d, expected -1\n", wine_dbgstr_w(global_idents[i]), id);
|
|
|
|
SysFreeString(bstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(context_idents); i++)
|
|
|
|
{
|
|
|
|
bstr = SysAllocString(context_idents[i]);
|
|
|
|
id = 0;
|
|
|
|
hr = IDispatchEx_GetDispID(dispex, bstr, 0, &id);
|
|
|
|
ok(hr == DISP_E_UNKNOWNNAME, "GetDispID(%s) returned %08x\n", wine_dbgstr_w(context_idents[i]), hr);
|
|
|
|
ok(id == -1, "[%s] id = %d, expected -1\n", wine_dbgstr_w(context_idents[i]), id);
|
|
|
|
SysFreeString(bstr);
|
|
|
|
}
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(global_code_test); i++)
|
|
|
|
{
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, global_code_test[i], NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText(%s) failed: %08x\n", wine_dbgstr_w(global_code_test[i]), hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, global_code_test[i], L"codeOnlyItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "ParseScriptText(%s) failed: %08x\n", wine_dbgstr_w(global_code_test[i]), hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(context_code_test); i++)
|
|
|
|
{
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnScriptError);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, context_code_test[i], NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(FAILED(hr), "ParseScriptText(%s) returned: %08x\n", wine_dbgstr_w(context_code_test[i]), hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnScriptError);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
|
|
|
|
SET_EXPECT(OnEnterScript);
|
|
|
|
SET_EXPECT(OnScriptError);
|
|
|
|
SET_EXPECT(OnLeaveScript);
|
|
|
|
hr = IActiveScriptParse_ParseScriptText(parse, context_code_test[i], L"codeOnlyItem", NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(FAILED(hr), "ParseScriptText(%s) returned: %08x\n", wine_dbgstr_w(context_code_test[i]), hr);
|
|
|
|
CHECK_CALLED(OnEnterScript);
|
|
|
|
CHECK_CALLED(OnScriptError);
|
|
|
|
CHECK_CALLED(OnLeaveScript);
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_DISCONNECTED);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
SET_EXPECT(OnStateChange_CLOSED);
|
|
|
|
hr = IActiveScript_Close(script);
|
|
|
|
ok(hr == S_OK, "Close failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_DISCONNECTED);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
CHECK_CALLED(OnStateChange_CLOSED);
|
|
|
|
|
|
|
|
ok(global_named_item_ref == 0, "global_named_item_ref = %u\n", global_named_item_ref);
|
|
|
|
ok(visible_named_item_ref == 0, "visible_named_item_ref = %u\n", visible_named_item_ref);
|
|
|
|
ok(visible_code_named_item_ref == 0, "visible_code_named_item_ref = %u\n", visible_code_named_item_ref);
|
2020-03-24 17:49:58 +01:00
|
|
|
ok(persistent_named_item_ref == 0, "persistent_named_item_ref = %u\n", persistent_named_item_ref);
|
2020-03-05 17:12:03 +01:00
|
|
|
|
|
|
|
test_state(script, SCRIPTSTATE_CLOSED);
|
|
|
|
IActiveScriptParse_Release(parse);
|
|
|
|
|
|
|
|
ref = IActiveScript_Release(script);
|
|
|
|
ok(!ref, "ref = %d\n", ref);
|
|
|
|
}
|
|
|
|
|
2019-12-12 13:54:03 +01:00
|
|
|
static void test_typeinfo(const WCHAR *parse_func_name)
|
|
|
|
{
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
const WCHAR *name;
|
|
|
|
UINT num_args;
|
|
|
|
} func[] =
|
|
|
|
{
|
|
|
|
{ L"emptyfn", 0 },
|
|
|
|
{ L"voidfn", 0 },
|
|
|
|
{ L"math", 2 },
|
|
|
|
{ L"foobar", 1 },
|
|
|
|
{ L"C", 0 },
|
|
|
|
{ L"funcvar", 2 },
|
|
|
|
{ L"f1", 1 },
|
|
|
|
{ L"f2", 1 }
|
|
|
|
};
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
const WCHAR *name;
|
|
|
|
} var[] =
|
|
|
|
{
|
|
|
|
{ L"global_var" },
|
|
|
|
{ L"uninit" },
|
|
|
|
{ L"obj" }
|
|
|
|
};
|
|
|
|
const WCHAR *source = L""
|
|
|
|
"var global_var = 42;\n"
|
|
|
|
|
|
|
|
"function emptyfn() { }\n"
|
|
|
|
"function voidfn() { return void(0); }\n"
|
|
|
|
"function math(x, y) { return x - y; }\n"
|
|
|
|
"function foobar(x) { return \"foobar\"; }\n"
|
|
|
|
|
|
|
|
"function C() {\n"
|
|
|
|
" this.x;\n"
|
|
|
|
" this.strret = function() { return \"ret\"; }\n"
|
|
|
|
"}\n"
|
|
|
|
|
|
|
|
"var uninit;\n"
|
|
|
|
"var obj = new C();\n"
|
|
|
|
|
|
|
|
"var funcvar = function(x, y) { return x * y; };\n"
|
|
|
|
"var native_func = decodeURI;\n"
|
|
|
|
|
|
|
|
"(function() {\n"
|
|
|
|
" f1 = function infuncexpr(x) { return 1; }\n"
|
|
|
|
" f2 = function infuncexpr(x) { return 2; }\n"
|
|
|
|
"})();\n";
|
|
|
|
UINT expected_funcs_cnt = parse_func_name ? 0 : ARRAY_SIZE(func);
|
|
|
|
UINT expected_vars_cnt = parse_func_name ? 0 : ARRAY_SIZE(var);
|
|
|
|
|
|
|
|
ITypeInfo *typeinfo, *typeinfo2;
|
|
|
|
ITypeComp *typecomp, *typecomp2;
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *script;
|
|
|
|
FUNCDESC *funcdesc;
|
|
|
|
VARDESC *vardesc;
|
|
|
|
IDispatchEx *disp;
|
|
|
|
DESCKIND desckind;
|
2019-12-13 13:59:55 +01:00
|
|
|
INT implTypeFlags;
|
|
|
|
UINT count, index;
|
|
|
|
HREFTYPE reftype;
|
2019-12-12 13:54:03 +01:00
|
|
|
BINDPTR bindptr;
|
|
|
|
MEMBERID memid;
|
|
|
|
TYPEATTR *attr;
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR str[64], *names = str;
|
2019-12-13 13:59:55 +01:00
|
|
|
BSTR bstr, bstrs[5];
|
|
|
|
void *obj;
|
2019-12-12 13:54:03 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (parse_func_name)
|
|
|
|
trace("Testing TypeInfo for function %s...\n", wine_dbgstr_w(parse_func_name));
|
|
|
|
else
|
|
|
|
trace("Testing TypeInfo for script dispatch...\n");
|
|
|
|
|
|
|
|
script = create_jscript();
|
|
|
|
|
|
|
|
hr = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hr == S_OK, "Could not get IActiveScriptParse iface: %08x\n", hr);
|
|
|
|
|
|
|
|
SET_EXPECT(GetLCID);
|
|
|
|
hr = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
|
|
|
ok(hr == S_OK, "SetScriptSite failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(GetLCID);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
hr = IActiveScriptParse_InitNew(parser);
|
|
|
|
ok(hr == S_OK, "InitNew failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_CONNECTED);
|
|
|
|
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
|
|
|
|
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_CONNECTED);
|
|
|
|
|
|
|
|
if (parse_func_name)
|
|
|
|
{
|
|
|
|
IActiveScriptParseProcedure2 *parse_proc;
|
|
|
|
IDispatch *proc_disp;
|
|
|
|
|
|
|
|
hr = IActiveScript_QueryInterface(script, &IID_IActiveScriptParseProcedure2, (void**)&parse_proc);
|
|
|
|
ok(hr == S_OK, "Could not get IActiveScriptParse: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IActiveScriptParseProcedure2_ParseProcedureText(parse_proc, source, NULL, parse_func_name,
|
|
|
|
NULL, NULL, NULL, 0, 0, SCRIPTPROC_IMPLICIT_THIS | SCRIPTPROC_IMPLICIT_PARENTS, &proc_disp);
|
|
|
|
ok(hr == S_OK, "ParseProcedureText failed: %08x\n", hr);
|
|
|
|
IActiveScriptParseProcedure2_Release(parse_proc);
|
|
|
|
|
|
|
|
hr = IDispatch_QueryInterface(proc_disp, &IID_IDispatchEx, (void**)&disp);
|
|
|
|
ok(hr == S_OK, "Could not get IDispatchEx: %08x\n", hr);
|
|
|
|
IDispatch_Release(proc_disp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parse_script(parser, source);
|
2020-03-05 17:12:03 +01:00
|
|
|
disp = get_script_dispatch(script, NULL);
|
2019-12-12 13:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDispatchEx_QueryInterface(disp, &IID_ITypeInfo, (void**)&typeinfo);
|
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface(IID_ITypeInfo) returned: %08x\n", hr);
|
|
|
|
hr = IDispatchEx_GetTypeInfo(disp, 1, LOCALE_USER_DEFAULT, &typeinfo);
|
|
|
|
ok(hr == DISP_E_BADINDEX, "GetTypeInfo returned: %08x\n", hr);
|
|
|
|
hr = IDispatchEx_GetTypeInfo(disp, 0, LOCALE_USER_DEFAULT, &typeinfo);
|
|
|
|
ok(hr == S_OK, "GetTypeInfo failed: %08x\n", hr);
|
|
|
|
hr = IDispatchEx_GetTypeInfo(disp, 0, LOCALE_USER_DEFAULT, &typeinfo2);
|
|
|
|
ok(hr == S_OK, "GetTypeInfo failed: %08x\n", hr);
|
|
|
|
ok(typeinfo != typeinfo2, "TypeInfo was not supposed to be shared.\n");
|
|
|
|
ITypeInfo_Release(typeinfo2);
|
|
|
|
|
2019-12-13 13:59:55 +01:00
|
|
|
obj = (void*)0xdeadbeef;
|
|
|
|
hr = ITypeInfo_CreateInstance(typeinfo, NULL, NULL, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "CreateInstance returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_CreateInstance(typeinfo, NULL, NULL, &obj);
|
|
|
|
ok(hr == TYPE_E_BADMODULEKIND, "CreateInstance returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_CreateInstance(typeinfo, NULL, &IID_IDispatch, &obj);
|
|
|
|
ok(hr == TYPE_E_BADMODULEKIND, "CreateInstance returned: %08x\n", hr);
|
|
|
|
ok(!obj, "Unexpected non-null obj %p.\n", obj);
|
|
|
|
|
|
|
|
hr = ITypeInfo_GetDocumentation(typeinfo, MEMBERID_NIL, &bstr, NULL, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "GetDocumentation(MEMBERID_NIL) failed: %08x\n", hr);
|
|
|
|
ok(!lstrcmpW(bstr, L"JScriptTypeInfo"), "Unexpected TypeInfo name %s\n", wine_dbgstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
2019-12-12 13:54:03 +01:00
|
|
|
hr = ITypeInfo_GetTypeAttr(typeinfo, &attr);
|
|
|
|
ok(hr == S_OK, "GetTypeAttr failed: %08x\n", hr);
|
|
|
|
ok(IsEqualGUID(&attr->guid, &IID_IScriptTypeInfo), "Unexpected GUID %s\n", wine_dbgstr_guid(&attr->guid));
|
|
|
|
ok(attr->lcid == LOCALE_USER_DEFAULT, "Unexpected LCID %u\n", attr->lcid);
|
|
|
|
ok(attr->memidConstructor == MEMBERID_NIL, "Unexpected constructor memid %u\n", attr->memidConstructor);
|
|
|
|
ok(attr->memidDestructor == MEMBERID_NIL, "Unexpected destructor memid %u\n", attr->memidDestructor);
|
|
|
|
ok(attr->cbSizeInstance == 4, "Unexpected cbSizeInstance %u\n", attr->cbSizeInstance);
|
|
|
|
ok(attr->typekind == TKIND_DISPATCH, "Unexpected typekind %u\n", attr->typekind);
|
|
|
|
ok(attr->cFuncs == expected_funcs_cnt, "Unexpected cFuncs %u\n", attr->cFuncs);
|
|
|
|
ok(attr->cVars == expected_vars_cnt, "Unexpected cVars %u\n", attr->cVars);
|
|
|
|
ok(attr->cImplTypes == 1, "Unexpected cImplTypes %u\n", attr->cImplTypes);
|
|
|
|
ok(attr->cbSizeVft == sizeof(IDispatchVtbl), "Unexpected cbSizeVft %u\n", attr->cbSizeVft);
|
|
|
|
ok(attr->cbAlignment == 4, "Unexpected cbAlignment %u\n", attr->cbAlignment);
|
|
|
|
ok(attr->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "Unexpected wTypeFlags 0x%x\n", attr->wTypeFlags);
|
|
|
|
ok(attr->tdescAlias.vt == VT_EMPTY, "Unexpected tdescAlias.vt %d\n", attr->tdescAlias.vt);
|
|
|
|
ok(attr->idldescType.wIDLFlags == IDLFLAG_NONE, "Unexpected idldescType.wIDLFlags 0x%x\n", attr->idldescType.wIDLFlags);
|
|
|
|
ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
|
|
|
|
|
2019-12-13 13:59:55 +01:00
|
|
|
/* The type inherits from IDispatch */
|
|
|
|
hr = ITypeInfo_GetImplTypeFlags(typeinfo, 0, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "GetImplTypeFlags returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetImplTypeFlags(typeinfo, 1, &implTypeFlags);
|
|
|
|
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetImplTypeFlags returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetImplTypeFlags(typeinfo, -1, &implTypeFlags);
|
|
|
|
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetImplTypeFlags returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetImplTypeFlags(typeinfo, 0, &implTypeFlags);
|
|
|
|
ok(hr == S_OK, "GetImplTypeFlags failed: %08x\n", hr);
|
|
|
|
ok(implTypeFlags == 0, "Unexpected implTypeFlags 0x%x\n", implTypeFlags);
|
|
|
|
|
|
|
|
hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, 0, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "GetRefTypeOfImplType returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, 1, &reftype);
|
|
|
|
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetRefTypeOfImplType returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, -1, &reftype);
|
|
|
|
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetRefTypeOfImplType failed: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, 0, &reftype);
|
|
|
|
ok(hr == S_OK, "GetRefTypeOfImplType failed: %08x\n", hr);
|
|
|
|
ok(reftype == 1, "Unexpected reftype %d\n", reftype);
|
|
|
|
|
|
|
|
hr = ITypeInfo_GetRefTypeInfo(typeinfo, reftype, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "GetRefTypeInfo returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetRefTypeInfo(typeinfo, -1, &typeinfo2);
|
|
|
|
ok(hr == E_INVALIDARG, "GetRefTypeInfo returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetRefTypeInfo(typeinfo, 4, &typeinfo2);
|
|
|
|
ok(hr == E_FAIL, "GetRefTypeInfo returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetRefTypeInfo(typeinfo, 0, &typeinfo2);
|
|
|
|
ok(hr == S_OK, "GetRefTypeInfo failed: %08x\n", hr);
|
|
|
|
ok(typeinfo == typeinfo2, "Unexpected TypeInfo %p (expected %p)\n", typeinfo2, typeinfo);
|
|
|
|
ITypeInfo_Release(typeinfo2);
|
|
|
|
hr = ITypeInfo_GetRefTypeInfo(typeinfo, reftype, &typeinfo2);
|
|
|
|
ok(hr == S_OK, "GetRefTypeInfo failed: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetDocumentation(typeinfo2, MEMBERID_NIL, &bstr, NULL, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "GetDocumentation(MEMBERID_NIL) failed: %08x\n", hr);
|
|
|
|
ok(!lstrcmpW(bstr, L"IDispatch"), "Unexpected TypeInfo name %s\n", wine_dbgstr_w(bstr));
|
|
|
|
ITypeInfo_Release(typeinfo2);
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
2019-12-12 13:54:03 +01:00
|
|
|
/* GetIDsOfNames looks into the inherited types as well */
|
|
|
|
wcscpy(str, L"queryinterface");
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, NULL, 1, &memid);
|
|
|
|
ok(hr == E_INVALIDARG, "GetIDsOfNames returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 1, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "GetIDsOfNames returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 0, &memid);
|
|
|
|
ok(hr == E_INVALIDARG, "GetIDsOfNames returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 1, &memid);
|
|
|
|
ok(hr == S_OK, "GetIDsOfNames failed: %08x\n", hr);
|
|
|
|
ok(!lstrcmpW(str, L"queryinterface"), "Unexpected string %s\n", wine_dbgstr_w(str));
|
|
|
|
if (expected_funcs_cnt)
|
|
|
|
{
|
|
|
|
wcscpy(str, L"Math");
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 1, &memid);
|
|
|
|
ok(hr == S_OK, "GetIDsOfNames failed: %08x\n", hr);
|
|
|
|
ok(!lstrcmpW(str, L"Math"), "Unexpected string %s\n", wine_dbgstr_w(str));
|
2019-12-13 13:59:55 +01:00
|
|
|
hr = ITypeInfo_GetNames(typeinfo, memid, NULL, 1, &count);
|
|
|
|
ok(hr == E_INVALIDARG, "GetNames returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetNames(typeinfo, memid, bstrs, 1, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "GetNames returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetNames(typeinfo, memid, bstrs, 0, &count);
|
|
|
|
ok(hr == S_OK, "GetNames failed: %08x\n", hr);
|
|
|
|
ok(count == 0, "Unexpected count %u\n", count);
|
|
|
|
hr = ITypeInfo_GetNames(typeinfo, memid, bstrs, ARRAY_SIZE(bstrs), &count);
|
|
|
|
ok(hr == S_OK, "GetNames failed: %08x\n", hr);
|
|
|
|
ok(count == 3, "Unexpected count %u\n", count);
|
|
|
|
ok(!lstrcmpW(bstrs[0], L"math"), "Unexpected function name %s\n", wine_dbgstr_w(bstrs[0]));
|
|
|
|
ok(!lstrcmpW(bstrs[1], L"x"), "Unexpected function first param name %s\n", wine_dbgstr_w(bstrs[1]));
|
|
|
|
ok(!lstrcmpW(bstrs[2], L"y"), "Unexpected function second param name %s\n", wine_dbgstr_w(bstrs[2]));
|
|
|
|
for (i = 0; i < count; i++) SysFreeString(bstrs[i]);
|
|
|
|
|
|
|
|
hr = ITypeInfo_GetMops(typeinfo, memid, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "GetMops returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetMops(typeinfo, memid, &bstr);
|
|
|
|
ok(hr == S_OK, "GetMops failed: %08x\n", hr);
|
|
|
|
ok(!bstr, "Unexpected non-null string %s\n", wine_dbgstr_w(bstr));
|
|
|
|
hr = ITypeInfo_GetMops(typeinfo, MEMBERID_NIL, &bstr);
|
|
|
|
ok(hr == S_OK, "GetMops failed: %08x\n", hr);
|
|
|
|
ok(!bstr, "Unexpected non-null string %s\n", wine_dbgstr_w(bstr));
|
|
|
|
|
|
|
|
/* These always fail */
|
|
|
|
obj = (void*)0xdeadbeef;
|
|
|
|
hr = ITypeInfo_AddressOfMember(typeinfo, memid, INVOKE_FUNC, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "AddressOfMember returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_AddressOfMember(typeinfo, memid, INVOKE_FUNC, &obj);
|
|
|
|
ok(hr == TYPE_E_BADMODULEKIND, "AddressOfMember returned: %08x\n", hr);
|
|
|
|
ok(!obj, "Unexpected non-null obj %p.\n", obj);
|
|
|
|
bstr = (BSTR)0xdeadbeef;
|
|
|
|
hr = ITypeInfo_GetDllEntry(typeinfo, memid, INVOKE_FUNC, &bstr, NULL, NULL);
|
|
|
|
ok(hr == TYPE_E_BADMODULEKIND, "GetDllEntry returned: %08x\n", hr);
|
|
|
|
ok(!bstr, "Unexpected non-null str %p.\n", bstr);
|
|
|
|
wcscpy(str, L"Invoke");
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 1, &memid);
|
|
|
|
ok(hr == S_OK, "GetIDsOfNames failed: %08x\n", hr);
|
|
|
|
obj = (void*)0xdeadbeef;
|
|
|
|
hr = ITypeInfo_AddressOfMember(typeinfo, memid, INVOKE_FUNC, &obj);
|
|
|
|
ok(hr == TYPE_E_BADMODULEKIND, "AddressOfMember returned: %08x\n", hr);
|
|
|
|
ok(!obj, "Unexpected non-null obj %p.\n", obj);
|
|
|
|
bstr = (BSTR)0xdeadbeef;
|
|
|
|
hr = ITypeInfo_GetDllEntry(typeinfo, memid, INVOKE_FUNC, &bstr, NULL, NULL);
|
|
|
|
ok(hr == TYPE_E_BADMODULEKIND, "GetDllEntry returned: %08x\n", hr);
|
|
|
|
ok(!bstr, "Unexpected non-null str %p.\n", bstr);
|
2019-12-12 13:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check variable descriptions */
|
|
|
|
hr = ITypeInfo_GetVarDesc(typeinfo, 0, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "GetVarDesc returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetVarDesc(typeinfo, 1337, &vardesc);
|
|
|
|
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetVarDesc returned: %08x\n", hr);
|
|
|
|
for (i = 0; i < expected_vars_cnt; i++)
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetVarDesc(typeinfo, i, &vardesc);
|
|
|
|
ok(hr == S_OK, "GetVarDesc(%u) failed: %08x\n", i, hr);
|
2019-12-13 13:59:55 +01:00
|
|
|
hr = ITypeInfo_GetDocumentation(typeinfo, vardesc->memid, &bstr, &bstrs[0], NULL, NULL);
|
|
|
|
ok(hr == S_OK, "[%u] GetDocumentation failed: %08x\n", i, hr);
|
|
|
|
ok(!lstrcmpW(bstr, var[i].name), "[%u] Unexpected variable name %s (expected %s)\n",
|
|
|
|
i, wine_dbgstr_w(bstr), wine_dbgstr_w(var[i].name));
|
|
|
|
ok(!bstrs[0], "[%u] Unexpected doc string %s\n", i, wine_dbgstr_w(bstrs[0]));
|
|
|
|
SysFreeString(bstr);
|
2019-12-12 13:54:03 +01:00
|
|
|
ok(vardesc->memid <= 0xFFFF, "[%u] Unexpected memid 0x%x\n", i, vardesc->memid);
|
|
|
|
ok(vardesc->lpstrSchema == NULL, "[%u] Unexpected lpstrSchema %p\n", i, vardesc->lpstrSchema);
|
|
|
|
ok(vardesc->oInst == 0, "[%u] Unexpected oInst %u\n", i, vardesc->oInst);
|
|
|
|
ok(vardesc->varkind == VAR_DISPATCH, "[%u] Unexpected varkind %d\n", i, vardesc->varkind);
|
|
|
|
ok(vardesc->wVarFlags == 0, "[%u] Unexpected wVarFlags 0x%x\n", i, vardesc->wVarFlags);
|
|
|
|
ok(vardesc->elemdescVar.tdesc.vt == VT_VARIANT,
|
|
|
|
"[%u] Unexpected variable type vt %d (expected %d)\n", i, vardesc->elemdescVar.tdesc.vt, 0);
|
|
|
|
ok(vardesc->elemdescVar.paramdesc.pparamdescex == NULL,
|
|
|
|
"[%u] Unexpected variable type pparamdescex %p\n", i, vardesc->elemdescVar.paramdesc.pparamdescex);
|
|
|
|
ok(vardesc->elemdescVar.paramdesc.wParamFlags == PARAMFLAG_NONE,
|
|
|
|
"[%u] Unexpected variable type wParamFlags 0x%x\n", i, vardesc->elemdescVar.paramdesc.wParamFlags);
|
|
|
|
ITypeInfo_ReleaseVarDesc(typeinfo, vardesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check function descriptions */
|
|
|
|
hr = ITypeInfo_GetFuncDesc(typeinfo, 0, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "GetFuncDesc returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetFuncDesc(typeinfo, 1337, &funcdesc);
|
|
|
|
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetFuncDesc returned: %08x\n", hr);
|
|
|
|
for (i = 0; i < expected_funcs_cnt; i++)
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetFuncDesc(typeinfo, i, &funcdesc);
|
|
|
|
ok(hr == S_OK, "GetFuncDesc(%u) failed: %08x\n", i, hr);
|
2019-12-13 13:59:55 +01:00
|
|
|
hr = ITypeInfo_GetDocumentation(typeinfo, funcdesc->memid, &bstr, &bstrs[0], NULL, NULL);
|
|
|
|
ok(hr == S_OK, "[%u] GetDocumentation failed: %08x\n", i, hr);
|
|
|
|
ok(!lstrcmpW(bstr, func[i].name), "[%u] Unexpected function name %s (expected %s)\n",
|
|
|
|
i, wine_dbgstr_w(bstr), wine_dbgstr_w(func[i].name));
|
|
|
|
ok(!bstrs[0], "[%u] Unexpected doc string %s\n", i, wine_dbgstr_w(bstrs[0]));
|
|
|
|
SysFreeString(bstr);
|
2019-12-12 13:54:03 +01:00
|
|
|
ok(funcdesc->memid <= 0xFFFF, "[%u] Unexpected memid 0x%x\n", i, funcdesc->memid);
|
|
|
|
ok(funcdesc->lprgscode == NULL, "[%u] Unexpected lprgscode %p\n", i, funcdesc->lprgscode);
|
|
|
|
ok(func[i].num_args ? (funcdesc->lprgelemdescParam != NULL) : (funcdesc->lprgelemdescParam == NULL),
|
|
|
|
"[%u] Unexpected lprgelemdescParam %p\n", i, funcdesc->lprgelemdescParam);
|
|
|
|
ok(funcdesc->funckind == FUNC_DISPATCH, "[%u] Unexpected funckind %u\n", i, funcdesc->funckind);
|
|
|
|
ok(funcdesc->invkind == INVOKE_FUNC, "[%u] Unexpected invkind %u\n", i, funcdesc->invkind);
|
|
|
|
ok(funcdesc->callconv == CC_STDCALL, "[%u] Unexpected callconv %u\n", i, funcdesc->callconv);
|
|
|
|
ok(funcdesc->cParams == func[i].num_args, "[%u] Unexpected cParams %d (expected %d)\n",
|
|
|
|
i, funcdesc->cParams, func[i].num_args);
|
|
|
|
ok(funcdesc->cParamsOpt == 0, "[%u] Unexpected cParamsOpt %d\n", i, funcdesc->cParamsOpt);
|
|
|
|
ok(funcdesc->cScodes == 0, "[%u] Unexpected cScodes %d\n", i, funcdesc->cScodes);
|
|
|
|
ok(funcdesc->wFuncFlags == 0, "[%u] Unexpected wFuncFlags 0x%x\n", i, funcdesc->wFuncFlags);
|
|
|
|
ok(funcdesc->elemdescFunc.tdesc.vt == VT_VARIANT,
|
|
|
|
"[%u] Unexpected return type vt %d\n", i, funcdesc->elemdescFunc.tdesc.vt);
|
|
|
|
ok(funcdesc->elemdescFunc.paramdesc.pparamdescex == NULL,
|
|
|
|
"[%u] Unexpected return type pparamdescex %p\n", i, funcdesc->elemdescFunc.paramdesc.pparamdescex);
|
|
|
|
ok(funcdesc->elemdescFunc.paramdesc.wParamFlags == PARAMFLAG_NONE,
|
|
|
|
"[%u] Unexpected return type wParamFlags 0x%x\n", i, funcdesc->elemdescFunc.paramdesc.wParamFlags);
|
|
|
|
if (funcdesc->lprgelemdescParam)
|
|
|
|
for (index = 0; index < funcdesc->cParams; index++)
|
|
|
|
{
|
|
|
|
ok(funcdesc->lprgelemdescParam[index].tdesc.vt == VT_VARIANT,
|
|
|
|
"[%u] Unexpected parameter %u vt %d\n", i, index, funcdesc->lprgelemdescParam[index].tdesc.vt);
|
|
|
|
ok(funcdesc->lprgelemdescParam[index].paramdesc.pparamdescex == NULL,
|
|
|
|
"[%u] Unexpected parameter %u pparamdescex %p\n", i, index, funcdesc->lprgelemdescParam[index].paramdesc.pparamdescex);
|
|
|
|
ok(funcdesc->lprgelemdescParam[index].paramdesc.wParamFlags == PARAMFLAG_NONE,
|
|
|
|
"[%u] Unexpected parameter %u wParamFlags 0x%x\n", i, index, funcdesc->lprgelemdescParam[index].paramdesc.wParamFlags);
|
|
|
|
}
|
|
|
|
ITypeInfo_ReleaseFuncDesc(typeinfo, funcdesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test TypeComp Binds */
|
|
|
|
hr = ITypeInfo_QueryInterface(typeinfo, &IID_ITypeComp, (void**)&typecomp);
|
|
|
|
ok(hr == S_OK, "QueryInterface(IID_ITypeComp) failed: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetTypeComp(typeinfo, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "GetTypeComp returned: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetTypeComp(typeinfo, &typecomp2);
|
|
|
|
ok(hr == S_OK, "GetTypeComp failed: %08x\n", hr);
|
|
|
|
ok(typecomp == typecomp2, "QueryInterface(IID_ITypeComp) and GetTypeComp returned different TypeComps\n");
|
|
|
|
ITypeComp_Release(typecomp2);
|
|
|
|
wcscpy(str, L"not_found");
|
|
|
|
hr = ITypeComp_Bind(typecomp, NULL, 0, 0, &typeinfo2, &desckind, &bindptr);
|
|
|
|
ok(hr == E_INVALIDARG, "Bind returned: %08x\n", hr);
|
|
|
|
hr = ITypeComp_Bind(typecomp, str, 0, 0, NULL, &desckind, &bindptr);
|
|
|
|
ok(hr == E_INVALIDARG, "Bind returned: %08x\n", hr);
|
|
|
|
hr = ITypeComp_Bind(typecomp, str, 0, 0, &typeinfo2, NULL, &bindptr);
|
|
|
|
ok(hr == E_INVALIDARG, "Bind returned: %08x\n", hr);
|
|
|
|
hr = ITypeComp_Bind(typecomp, str, 0, 0, &typeinfo2, &desckind, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Bind returned: %08x\n", hr);
|
|
|
|
hr = ITypeComp_Bind(typecomp, str, 0, 0, &typeinfo2, &desckind, &bindptr);
|
|
|
|
ok(hr == S_OK, "Bind failed: %08x\n", hr);
|
|
|
|
ok(desckind == DESCKIND_NONE, "Unexpected desckind %u\n", desckind);
|
|
|
|
wcscpy(str, L"addRef");
|
|
|
|
hr = ITypeComp_Bind(typecomp, str, 0, 0, &typeinfo2, &desckind, &bindptr);
|
|
|
|
ok(hr == S_OK, "Bind failed: %08x\n", hr);
|
|
|
|
ok(desckind == DESCKIND_FUNCDESC, "Unexpected desckind %u\n", desckind);
|
|
|
|
ok(!lstrcmpW(str, L"addRef"), "Unexpected string %s\n", wine_dbgstr_w(str));
|
|
|
|
ITypeInfo_ReleaseFuncDesc(typeinfo2, bindptr.lpfuncdesc);
|
|
|
|
ITypeInfo_Release(typeinfo2);
|
|
|
|
for (i = 0; i < expected_vars_cnt; i++)
|
|
|
|
{
|
|
|
|
wcscpy(str, var[i].name);
|
|
|
|
hr = ITypeComp_Bind(typecomp, str, 0, INVOKE_PROPERTYGET, &typeinfo2, &desckind, &bindptr);
|
|
|
|
ok(hr == S_OK, "Bind failed: %08x\n", hr);
|
|
|
|
ok(desckind == DESCKIND_VARDESC, "Unexpected desckind %u\n", desckind);
|
|
|
|
ITypeInfo_ReleaseVarDesc(typeinfo2, bindptr.lpvardesc);
|
|
|
|
ITypeInfo_Release(typeinfo2);
|
|
|
|
}
|
|
|
|
for (i = 0; i < expected_funcs_cnt; i++)
|
|
|
|
{
|
|
|
|
wcscpy(str, func[i].name);
|
|
|
|
hr = ITypeComp_Bind(typecomp, str, 0, INVOKE_FUNC, &typeinfo2, &desckind, &bindptr);
|
|
|
|
ok(hr == S_OK, "Bind failed: %08x\n", hr);
|
|
|
|
ok(desckind == DESCKIND_FUNCDESC, "Unexpected desckind %u\n", desckind);
|
|
|
|
ITypeInfo_ReleaseFuncDesc(typeinfo2, bindptr.lpfuncdesc);
|
|
|
|
ITypeInfo_Release(typeinfo2);
|
|
|
|
}
|
|
|
|
wcscpy(str, L"JScriptTypeInfo");
|
|
|
|
hr = ITypeComp_BindType(typecomp, NULL, 0, &typeinfo2, &typecomp2);
|
|
|
|
ok(hr == E_INVALIDARG, "BindType returned: %08x\n", hr);
|
|
|
|
hr = ITypeComp_BindType(typecomp, str, 0, NULL, &typecomp2);
|
|
|
|
ok(hr == E_INVALIDARG, "BindType returned: %08x\n", hr);
|
|
|
|
hr = ITypeComp_BindType(typecomp, str, 0, &typeinfo2, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "BindType returned: %08x\n", hr);
|
|
|
|
hr = ITypeComp_BindType(typecomp, str, 0, &typeinfo2, &typecomp2);
|
|
|
|
ok(hr == S_OK, "BindType failed: %08x\n", hr);
|
|
|
|
ok(!typeinfo2, "Unexpected TypeInfo %p (expected null)\n", typeinfo2);
|
|
|
|
ok(!typecomp2, "Unexpected TypeComp %p (expected null)\n", typecomp2);
|
|
|
|
wcscpy(str, L"C");
|
|
|
|
hr = ITypeComp_BindType(typecomp, str, 0, &typeinfo2, &typecomp2);
|
|
|
|
ok(hr == S_OK, "BindType failed: %08x\n", hr);
|
|
|
|
ok(!typeinfo2, "Unexpected TypeInfo %p (expected null)\n", typeinfo2);
|
|
|
|
ok(!typecomp2, "Unexpected TypeComp %p (expected null)\n", typecomp2);
|
|
|
|
wcscpy(str, L"IDispatch");
|
|
|
|
hr = ITypeComp_BindType(typecomp, str, 0, &typeinfo2, &typecomp2);
|
|
|
|
ok(hr == S_OK, "BindType failed: %08x\n", hr);
|
|
|
|
ok(!typeinfo2, "Unexpected TypeInfo %p (expected null)\n", typeinfo2);
|
|
|
|
ok(!typecomp2, "Unexpected TypeComp %p (expected null)\n", typecomp2);
|
|
|
|
ITypeComp_Release(typecomp);
|
|
|
|
|
|
|
|
/* Updating the script won't update the typeinfo obtained before,
|
|
|
|
but it will be reflected in any typeinfo obtained afterwards. */
|
|
|
|
if (!parse_func_name)
|
|
|
|
{
|
|
|
|
parse_script(parser, L""
|
|
|
|
"var new_var;\n"
|
|
|
|
"function new_func() { }\n");
|
|
|
|
|
|
|
|
hr = IDispatchEx_GetTypeInfo(disp, 0, LOCALE_USER_DEFAULT, &typeinfo2);
|
|
|
|
ok(hr == S_OK, "GetTypeInfo failed: %08x\n", hr);
|
|
|
|
hr = ITypeInfo_GetTypeAttr(typeinfo, &attr);
|
|
|
|
ok(hr == S_OK, "GetTypeAttr failed: %08x\n", hr);
|
|
|
|
ok(attr->cFuncs == expected_funcs_cnt, "Unexpected cFuncs %u\n", attr->cFuncs);
|
|
|
|
ok(attr->cVars == expected_vars_cnt, "Unexpected cVars %u\n", attr->cVars);
|
|
|
|
ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
|
|
|
|
hr = ITypeInfo_GetTypeAttr(typeinfo2, &attr);
|
|
|
|
ok(hr == S_OK, "GetTypeAttr failed: %08x\n", hr);
|
|
|
|
ok(attr->cFuncs == expected_funcs_cnt + 1, "Unexpected cFuncs %u\n", attr->cFuncs);
|
|
|
|
ok(attr->cVars == expected_vars_cnt + 1, "Unexpected cVars %u\n", attr->cVars);
|
|
|
|
ITypeInfo_ReleaseTypeAttr(typeinfo2, attr);
|
|
|
|
ITypeInfo_Release(typeinfo2);
|
|
|
|
|
|
|
|
/* Adding an identifier that differs only in case gives an error
|
|
|
|
when retrieving the TypeInfo, even though it is valid jscript. */
|
|
|
|
parse_script(parser, L"var NEW_FUNC;\n");
|
|
|
|
hr = IDispatchEx_GetTypeInfo(disp, 0, LOCALE_USER_DEFAULT, &typeinfo2);
|
|
|
|
ok(hr == TYPE_E_AMBIGUOUSNAME, "GetTypeInfo returned: %08x\n", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
IDispatchEx_Release(disp);
|
|
|
|
IActiveScriptParse_Release(parser);
|
|
|
|
|
|
|
|
SET_EXPECT(OnStateChange_DISCONNECTED);
|
|
|
|
SET_EXPECT(OnStateChange_INITIALIZED);
|
|
|
|
SET_EXPECT(OnStateChange_CLOSED);
|
|
|
|
hr = IActiveScript_Close(script);
|
|
|
|
ok(hr == S_OK, "Close failed: %08x\n", hr);
|
|
|
|
CHECK_CALLED(OnStateChange_DISCONNECTED);
|
|
|
|
CHECK_CALLED(OnStateChange_INITIALIZED);
|
|
|
|
CHECK_CALLED(OnStateChange_CLOSED);
|
|
|
|
|
|
|
|
IActiveScript_Release(script);
|
|
|
|
}
|
|
|
|
|
2010-09-21 15:58:48 +02:00
|
|
|
static BOOL check_jscript(void)
|
|
|
|
{
|
|
|
|
IActiveScriptProperty *script_prop;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
|
|
|
&IID_IActiveScriptProperty, (void**)&script_prop);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
IActiveScriptProperty_Release(script_prop);
|
|
|
|
|
|
|
|
return hres == S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-24 21:53:14 +01:00
|
|
|
START_TEST(jscript)
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2010-09-21 15:58:48 +02:00
|
|
|
if(check_jscript()) {
|
2012-03-26 11:42:13 +02:00
|
|
|
trace("Testing JScript object...\n");
|
2010-09-21 15:58:48 +02:00
|
|
|
test_jscript();
|
|
|
|
test_jscript2();
|
2011-02-21 17:49:32 +01:00
|
|
|
test_jscript_uninitializing();
|
2011-07-18 18:05:13 +02:00
|
|
|
test_aggregation();
|
2019-11-07 18:17:28 +01:00
|
|
|
test_code_persistence();
|
2020-03-05 17:12:03 +01:00
|
|
|
test_named_items();
|
2019-12-12 13:54:03 +01:00
|
|
|
test_typeinfo(NULL);
|
|
|
|
test_typeinfo(L"some_func_name");
|
2012-03-26 11:42:13 +02:00
|
|
|
|
|
|
|
trace("Testing JScriptEncode object...\n");
|
|
|
|
engine_clsid = &CLSID_JScriptEncode;
|
|
|
|
test_jscript();
|
2010-09-21 15:58:48 +02:00
|
|
|
}else {
|
|
|
|
win_skip("Broken engine, probably too old\n");
|
|
|
|
}
|
2008-03-24 21:53:14 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|