2008-09-05 02:38:44 +02: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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#define CONST_VTABLE
|
|
|
|
|
|
|
|
#include <ole2.h>
|
|
|
|
#include <dispex.h>
|
|
|
|
#include <activscp.h>
|
|
|
|
|
|
|
|
#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
|
2012-10-04 14:57:46 +02: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
|
2012-10-04 14:57:46 +02:00
|
|
|
#define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_32_Release
|
|
|
|
#define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_32_ParseProcedureText
|
2012-07-30 12:02:01 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
static const CLSID CLSID_JScript =
|
|
|
|
{0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
|
2012-03-26 11:43:23 +02:00
|
|
|
static const CLSID CLSID_JScriptEncode =
|
|
|
|
{0xf414c262,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
|
2008-09-05 02:38:44 +02:00
|
|
|
|
|
|
|
#define DEFINE_EXPECT(func) \
|
|
|
|
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
|
|
|
|
|
|
|
|
#define SET_EXPECT(func) \
|
|
|
|
expect_ ## func = TRUE
|
|
|
|
|
|
|
|
#define CHECK_EXPECT2(func) \
|
|
|
|
do { \
|
|
|
|
ok(expect_ ##func, "unexpected call " #func "\n"); \
|
|
|
|
called_ ## func = TRUE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_EXPECT(func) \
|
|
|
|
do { \
|
|
|
|
CHECK_EXPECT2(func); \
|
|
|
|
expect_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_CALLED(func) \
|
|
|
|
do { \
|
|
|
|
ok(called_ ## func, "expected " #func "\n"); \
|
|
|
|
expect_ ## func = called_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
2008-09-09 01:22:31 +02:00
|
|
|
DEFINE_EXPECT(global_propget_d);
|
|
|
|
DEFINE_EXPECT(global_propget_i);
|
2008-09-09 01:24:02 +02:00
|
|
|
DEFINE_EXPECT(global_propput_d);
|
|
|
|
DEFINE_EXPECT(global_propput_i);
|
2014-11-28 16:18:32 +01:00
|
|
|
DEFINE_EXPECT(global_propputref_d);
|
|
|
|
DEFINE_EXPECT(global_propputref_i);
|
2011-12-15 15:42:41 +01:00
|
|
|
DEFINE_EXPECT(global_propdelete_d);
|
2012-12-17 13:36:55 +01:00
|
|
|
DEFINE_EXPECT(global_nopropdelete_d);
|
2015-10-15 12:58:38 +02:00
|
|
|
DEFINE_EXPECT(global_propdeleteerror_d);
|
2008-09-09 01:25:05 +02:00
|
|
|
DEFINE_EXPECT(global_success_d);
|
|
|
|
DEFINE_EXPECT(global_success_i);
|
2009-08-10 12:57:42 +02:00
|
|
|
DEFINE_EXPECT(global_notexists_d);
|
2012-04-17 16:26:16 +02:00
|
|
|
DEFINE_EXPECT(global_propargput_d);
|
|
|
|
DEFINE_EXPECT(global_propargput_i);
|
2012-05-01 15:05:21 +02:00
|
|
|
DEFINE_EXPECT(global_testargtypes_i);
|
2019-05-20 21:05:25 +02:00
|
|
|
DEFINE_EXPECT(global_calleval_i);
|
2011-09-02 12:24:12 +02:00
|
|
|
DEFINE_EXPECT(puredisp_prop_d);
|
|
|
|
DEFINE_EXPECT(puredisp_noprop_d);
|
2012-12-24 11:38:28 +01:00
|
|
|
DEFINE_EXPECT(puredisp_value);
|
|
|
|
DEFINE_EXPECT(dispexfunc_value);
|
2012-12-17 13:36:44 +01:00
|
|
|
DEFINE_EXPECT(testobj_delete_test);
|
|
|
|
DEFINE_EXPECT(testobj_delete_nodelete);
|
2009-09-02 12:25:21 +02:00
|
|
|
DEFINE_EXPECT(testobj_value);
|
2014-09-16 20:42:33 +02:00
|
|
|
DEFINE_EXPECT(testobj_construct);
|
2009-09-06 19:10:06 +02:00
|
|
|
DEFINE_EXPECT(testobj_prop_d);
|
2012-09-13 14:34:25 +02:00
|
|
|
DEFINE_EXPECT(testobj_withprop_d);
|
|
|
|
DEFINE_EXPECT(testobj_withprop_i);
|
2009-09-06 19:10:06 +02:00
|
|
|
DEFINE_EXPECT(testobj_noprop_d);
|
2010-12-29 16:02:25 +01:00
|
|
|
DEFINE_EXPECT(testobj_onlydispid_d);
|
|
|
|
DEFINE_EXPECT(testobj_onlydispid_i);
|
2014-06-12 10:44:03 +02:00
|
|
|
DEFINE_EXPECT(testobj_notexists_d);
|
2019-05-17 16:39:32 +02:00
|
|
|
DEFINE_EXPECT(testobj_newenum);
|
|
|
|
DEFINE_EXPECT(enumvariant_next_0);
|
|
|
|
DEFINE_EXPECT(enumvariant_next_1);
|
|
|
|
DEFINE_EXPECT(enumvariant_reset);
|
2008-12-15 22:24:33 +01:00
|
|
|
DEFINE_EXPECT(GetItemInfo_testVal);
|
2010-10-09 16:43:48 +02:00
|
|
|
DEFINE_EXPECT(ActiveScriptSite_OnScriptError);
|
2010-10-19 23:14:35 +02:00
|
|
|
DEFINE_EXPECT(invoke_func);
|
2011-12-15 15:42:41 +01:00
|
|
|
DEFINE_EXPECT(DeleteMemberByDispID);
|
2012-12-17 13:36:55 +01:00
|
|
|
DEFINE_EXPECT(DeleteMemberByDispID_false);
|
2015-10-15 12:58:38 +02:00
|
|
|
DEFINE_EXPECT(DeleteMemberByDispID_error);
|
2015-06-02 14:45:20 +02:00
|
|
|
DEFINE_EXPECT(BindHandler);
|
2008-09-09 01:22:31 +02:00
|
|
|
|
|
|
|
#define DISPID_GLOBAL_TESTPROPGET 0x1000
|
2008-09-09 01:24:02 +02:00
|
|
|
#define DISPID_GLOBAL_TESTPROPPUT 0x1001
|
2008-09-09 01:25:05 +02:00
|
|
|
#define DISPID_GLOBAL_REPORTSUCCESS 0x1002
|
2008-09-09 01:25:23 +02:00
|
|
|
#define DISPID_GLOBAL_TRACE 0x1003
|
|
|
|
#define DISPID_GLOBAL_OK 0x1004
|
2008-09-10 21:12:19 +02:00
|
|
|
#define DISPID_GLOBAL_GETVT 0x1005
|
2008-09-19 00:43:37 +02:00
|
|
|
#define DISPID_GLOBAL_TESTOBJ 0x1006
|
2012-03-28 15:04:28 +02:00
|
|
|
#define DISPID_GLOBAL_GETNULLBSTR 0x1007
|
2009-09-06 19:09:30 +02:00
|
|
|
#define DISPID_GLOBAL_NULL_DISP 0x1008
|
2009-09-27 20:59:28 +02:00
|
|
|
#define DISPID_GLOBAL_TESTTHIS 0x1009
|
|
|
|
#define DISPID_GLOBAL_TESTTHIS2 0x100a
|
2009-10-19 20:41:32 +02:00
|
|
|
#define DISPID_GLOBAL_INVOKEVERSION 0x100b
|
2010-10-19 23:14:35 +02:00
|
|
|
#define DISPID_GLOBAL_CREATEARRAY 0x100c
|
|
|
|
#define DISPID_GLOBAL_PROPGETFUNC 0x100d
|
|
|
|
#define DISPID_GLOBAL_OBJECT_FLAG 0x100e
|
2010-12-28 15:40:39 +01:00
|
|
|
#define DISPID_GLOBAL_ISWIN64 0x100f
|
2011-06-21 17:45:50 +02:00
|
|
|
#define DISPID_GLOBAL_PUREDISP 0x1010
|
2012-03-28 15:04:28 +02:00
|
|
|
#define DISPID_GLOBAL_ISNULLBSTR 0x1011
|
2012-04-17 16:26:16 +02:00
|
|
|
#define DISPID_GLOBAL_PROPARGPUT 0x1012
|
2012-05-01 15:05:21 +02:00
|
|
|
#define DISPID_GLOBAL_SHORTPROP 0x1013
|
|
|
|
#define DISPID_GLOBAL_GETSHORT 0x1014
|
|
|
|
#define DISPID_GLOBAL_TESTARGTYPES 0x1015
|
2012-05-04 15:59:43 +02:00
|
|
|
#define DISPID_GLOBAL_INTPROP 0x1016
|
2012-12-05 14:49:42 +01:00
|
|
|
#define DISPID_GLOBAL_DISPUNK 0x1017
|
2012-12-13 12:08:34 +01:00
|
|
|
#define DISPID_GLOBAL_TESTRES 0x1018
|
|
|
|
#define DISPID_GLOBAL_TESTNORES 0x1019
|
2012-12-24 11:38:28 +01:00
|
|
|
#define DISPID_GLOBAL_DISPEXFUNC 0x101a
|
2014-11-28 16:18:32 +01:00
|
|
|
#define DISPID_GLOBAL_TESTPROPPUTREF 0x101b
|
2015-01-13 21:46:02 +01:00
|
|
|
#define DISPID_GLOBAL_GETSCRIPTSTATE 0x101c
|
2015-06-02 14:45:20 +02:00
|
|
|
#define DISPID_GLOBAL_BINDEVENTHANDLER 0x101d
|
2019-05-17 16:39:32 +02:00
|
|
|
#define DISPID_GLOBAL_TESTENUMOBJ 0x101e
|
2019-05-20 21:05:25 +02:00
|
|
|
#define DISPID_GLOBAL_CALLEVAL 0x101f
|
2012-05-04 15:59:43 +02:00
|
|
|
|
2015-10-15 12:58:38 +02:00
|
|
|
#define DISPID_GLOBAL_TESTPROPDELETE 0x2000
|
|
|
|
#define DISPID_GLOBAL_TESTNOPROPDELETE 0x2001
|
|
|
|
#define DISPID_GLOBAL_TESTPROPDELETEERROR 0x2002
|
2008-09-09 01:22:31 +02:00
|
|
|
|
2009-09-06 19:10:06 +02:00
|
|
|
#define DISPID_TESTOBJ_PROP 0x2000
|
2010-12-29 16:02:25 +01:00
|
|
|
#define DISPID_TESTOBJ_ONLYDISPID 0x2001
|
2012-09-13 14:34:25 +02:00
|
|
|
#define DISPID_TESTOBJ_WITHPROP 0x2002
|
2009-09-06 19:10:06 +02:00
|
|
|
|
2014-10-02 08:09:10 +02:00
|
|
|
#define JS_E_OUT_OF_MEMORY 0x800a03ec
|
2012-03-26 11:43:23 +02:00
|
|
|
#define JS_E_INVALID_CHAR 0x800a03f6
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
static const WCHAR testW[] = {'t','e','s','t',0};
|
2008-12-16 16:42:50 +01:00
|
|
|
static const CHAR testA[] = "test";
|
2008-12-15 22:24:33 +01:00
|
|
|
static const WCHAR test_valW[] = {'t','e','s','t','V','a','l',0};
|
2008-12-16 16:42:50 +01:00
|
|
|
static const CHAR test_valA[] = "testVal";
|
2012-10-04 14:57:46 +02:00
|
|
|
static const WCHAR emptyW[] = {0};
|
2008-09-05 02:38:44 +02:00
|
|
|
|
2012-12-12 13:12:39 +01:00
|
|
|
static BOOL strict_dispid_check, testing_expr;
|
2008-09-09 01:25:23 +02:00
|
|
|
static const char *test_name = "(null)";
|
2009-09-27 20:59:28 +02:00
|
|
|
static IDispatch *script_disp;
|
2012-01-12 13:43:38 +01:00
|
|
|
static int invoke_version;
|
2010-10-09 16:43:48 +02:00
|
|
|
static IActiveScriptError *script_error;
|
2015-01-13 21:46:02 +01:00
|
|
|
static IActiveScript *script_engine;
|
2012-03-26 11:43:23 +02:00
|
|
|
static const CLSID *engine_clsid = &CLSID_JScript;
|
2008-09-09 01:25:23 +02:00
|
|
|
|
2011-09-18 19:38:18 +02:00
|
|
|
/* Returns true if the user interface is in English. Note that this does not
|
|
|
|
* presume of the formatting of dates, numbers, etc.
|
|
|
|
*/
|
|
|
|
static BOOL is_lang_english(void)
|
|
|
|
{
|
|
|
|
static HMODULE hkernel32 = NULL;
|
|
|
|
static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
|
|
|
|
static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
|
|
|
|
|
|
|
|
if (!hkernel32)
|
|
|
|
{
|
|
|
|
hkernel32 = GetModuleHandleA("kernel32.dll");
|
|
|
|
pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
|
|
|
|
pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
|
|
|
|
}
|
|
|
|
if (pGetThreadUILanguage)
|
|
|
|
return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
|
|
|
|
if (pGetUserDefaultUILanguage)
|
|
|
|
return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
|
|
|
|
|
|
|
|
return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
|
|
|
|
}
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
static BSTR a2bstr(const char *str)
|
|
|
|
{
|
|
|
|
BSTR ret;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
|
|
|
ret = SysAllocStringLen(NULL, len-1);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-09-09 01:22:31 +02:00
|
|
|
static int strcmp_wa(LPCWSTR strw, const char *stra)
|
|
|
|
{
|
2008-09-11 15:13:10 +02:00
|
|
|
CHAR buf[512];
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
|
|
|
|
return lstrcmpA(buf, stra);
|
2008-09-09 01:22:31 +02:00
|
|
|
}
|
|
|
|
|
2009-10-19 20:41:32 +02:00
|
|
|
#define test_grfdex(a,b) _test_grfdex(__LINE__,a,b)
|
|
|
|
static void _test_grfdex(unsigned line, DWORD grfdex, DWORD expect)
|
|
|
|
{
|
|
|
|
expect |= invoke_version << 28;
|
|
|
|
ok_(__FILE__,line)(grfdex == expect, "grfdex = %x, expected %x\n", grfdex, expect);
|
|
|
|
}
|
|
|
|
|
2019-05-17 16:39:32 +02:00
|
|
|
static HRESULT WINAPI EnumVARIANT_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IEnumVARIANT))
|
|
|
|
*ppv = iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI EnumVARIANT_AddRef(IEnumVARIANT *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI EnumVARIANT_Release(IEnumVARIANT *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int EnumVARIANT_index = 0;
|
|
|
|
static int EnumVARIANT_next_0_count = 0;
|
|
|
|
static HRESULT WINAPI EnumVARIANT_Next(
|
|
|
|
IEnumVARIANT *This,
|
|
|
|
ULONG celt,
|
|
|
|
VARIANT *rgVar,
|
|
|
|
ULONG *pCeltFetched)
|
|
|
|
{
|
|
|
|
ok(rgVar != NULL, "rgVar is NULL\n");
|
|
|
|
ok(celt == 1, "celt = %d\n", celt);
|
|
|
|
ok(pCeltFetched == NULL, "pCeltFetched is not NULL\n");
|
|
|
|
|
|
|
|
if (!rgVar)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
if (EnumVARIANT_index == 0)
|
|
|
|
{
|
|
|
|
EnumVARIANT_next_0_count--;
|
|
|
|
if (EnumVARIANT_next_0_count <= 0)
|
|
|
|
CHECK_EXPECT(enumvariant_next_0);
|
|
|
|
|
|
|
|
V_VT(rgVar) = VT_I4;
|
|
|
|
V_I4(rgVar) = 123;
|
|
|
|
|
|
|
|
if (pCeltFetched)
|
|
|
|
*pCeltFetched = 1;
|
|
|
|
EnumVARIANT_index++;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK_EXPECT(enumvariant_next_1);
|
|
|
|
|
|
|
|
if (pCeltFetched)
|
|
|
|
*pCeltFetched = 0;
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumVARIANT_Skip(
|
|
|
|
IEnumVARIANT *This,
|
|
|
|
ULONG celt)
|
|
|
|
{
|
|
|
|
ok(0, "EnumVariant_Skip: unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
static HRESULT WINAPI EnumVARIANT_Reset(
|
|
|
|
IEnumVARIANT *This)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(enumvariant_reset);
|
|
|
|
EnumVARIANT_index = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumVARIANT_Clone(
|
|
|
|
IEnumVARIANT *This,
|
|
|
|
IEnumVARIANT **ppEnum)
|
|
|
|
{
|
|
|
|
ok(0, "EnumVariant_Clone: unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IEnumVARIANTVtbl testEnumVARIANTVtbl = {
|
|
|
|
EnumVARIANT_QueryInterface,
|
|
|
|
EnumVARIANT_AddRef,
|
|
|
|
EnumVARIANT_Release,
|
|
|
|
EnumVARIANT_Next,
|
|
|
|
EnumVARIANT_Skip,
|
|
|
|
EnumVARIANT_Reset,
|
|
|
|
EnumVARIANT_Clone
|
|
|
|
};
|
|
|
|
|
|
|
|
static IEnumVARIANT testEnumVARIANT = { &testEnumVARIANTVtbl };
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDispatch)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDispatchEx))
|
|
|
|
*ppv = iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2012-12-24 11:38:28 +01:00
|
|
|
static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2015-06-02 14:45:20 +02:00
|
|
|
static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
|
|
|
|
VARIANT *res, EXCEPINFO *pei, IServiceProvider *pspCaller)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
|
|
|
|
{
|
2009-08-19 13:36:31 +02:00
|
|
|
ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
|
2008-09-05 02:38:44 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-05-17 16:39:32 +02:00
|
|
|
static HRESULT WINAPI testObj_Invoke(IDispatchEx *iface, DISPID id,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
|
|
|
|
VARIANT *pvarRes, EXCEPINFO *pei, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
switch(id) {
|
|
|
|
case DISPID_NEWENUM:
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(pei == NULL, "pei != NULL\n");
|
|
|
|
|
|
|
|
CHECK_EXPECT(testobj_newenum);
|
|
|
|
V_VT(pvarRes) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(pvarRes) = (IDispatch*)&testEnumVARIANT;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(0, "unexpected call %x\n", id);
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
|
2009-09-06 19:10:06 +02:00
|
|
|
static HRESULT WINAPI testObj_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
|
2008-09-19 00:43:37 +02:00
|
|
|
{
|
2009-09-06 19:10:06 +02:00
|
|
|
if(!strcmp_wa(bstrName, "prop")) {
|
|
|
|
CHECK_EXPECT(testobj_prop_d);
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2009-09-06 19:10:06 +02:00
|
|
|
*pid = DISPID_TESTOBJ_PROP;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-09-13 14:34:25 +02:00
|
|
|
if(!strcmp_wa(bstrName, "withProp")) {
|
|
|
|
CHECK_EXPECT(testobj_withprop_d);
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive|fdexNameImplicit);
|
|
|
|
*pid = DISPID_TESTOBJ_WITHPROP;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2009-09-06 19:10:06 +02:00
|
|
|
if(!strcmp_wa(bstrName, "noprop")) {
|
|
|
|
CHECK_EXPECT(testobj_noprop_d);
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2009-09-06 19:10:06 +02:00
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
2010-12-29 16:02:25 +01:00
|
|
|
if(!strcmp_wa(bstrName, "onlyDispID")) {
|
|
|
|
if(strict_dispid_check)
|
|
|
|
CHECK_EXPECT(testobj_onlydispid_d);
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_TESTOBJ_ONLYDISPID;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2014-06-12 10:44:03 +02:00
|
|
|
if(!strcmp_wa(bstrName, "notExists")) {
|
|
|
|
CHECK_EXPECT(testobj_notexists_d);
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
2009-09-06 19:10:06 +02:00
|
|
|
|
|
|
|
ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName));
|
2008-09-19 00:43:37 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-09-02 12:25:21 +02:00
|
|
|
static HRESULT WINAPI testObj_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
|
2008-09-19 00:43:37 +02:00
|
|
|
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
|
|
|
|
{
|
2012-03-08 14:28:16 +01:00
|
|
|
ok(pspCaller != NULL, "pspCaller = NULL\n");
|
|
|
|
|
2009-09-02 12:25:21 +02:00
|
|
|
switch(id) {
|
|
|
|
case DISPID_VALUE:
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
2010-10-19 23:14:35 +02:00
|
|
|
switch(wFlags) {
|
|
|
|
case INVOKE_PROPERTYGET:
|
|
|
|
CHECK_EXPECT(testobj_value);
|
|
|
|
ok(!pdp->rgvarg, "rgvarg != NULL\n");
|
|
|
|
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
break;
|
|
|
|
case INVOKE_FUNC:
|
|
|
|
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
break;
|
|
|
|
case INVOKE_FUNC|INVOKE_PROPERTYGET:
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
break;
|
2014-09-16 20:42:33 +02:00
|
|
|
case DISPATCH_CONSTRUCT:
|
|
|
|
CHECK_EXPECT(testobj_construct);
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
break;
|
2010-10-19 23:14:35 +02:00
|
|
|
default:
|
|
|
|
ok(0, "invalid flag (%x)\n", wFlags);
|
|
|
|
}
|
|
|
|
|
2009-09-02 12:25:21 +02:00
|
|
|
V_VT(pvarRes) = VT_I4;
|
|
|
|
V_I4(pvarRes) = 1;
|
|
|
|
return S_OK;
|
2010-12-29 16:02:25 +01:00
|
|
|
case DISPID_TESTOBJ_ONLYDISPID:
|
|
|
|
if(strict_dispid_check)
|
|
|
|
CHECK_EXPECT(testobj_onlydispid_i);
|
|
|
|
ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgvarg, "rgvarg != NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
2012-09-13 14:34:25 +02:00
|
|
|
case DISPID_TESTOBJ_WITHPROP:
|
|
|
|
CHECK_EXPECT(testobj_withprop_i);
|
|
|
|
|
|
|
|
ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgvarg, "rgvarg != NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_I4;
|
|
|
|
V_I4(pvarRes) = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
2009-09-02 12:25:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ok(0, "unexpected call %x\n", id);
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
2008-09-19 00:43:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testObj_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
|
|
|
|
{
|
2012-12-17 13:36:44 +01:00
|
|
|
if(!strcmp_wa(bstrName, "deleteTest")) {
|
|
|
|
CHECK_EXPECT(testobj_delete_test);
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if(!strcmp_wa(bstrName, "noDeleteTest")) {
|
|
|
|
CHECK_EXPECT(testobj_delete_nodelete);
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
2008-09-19 00:43:37 +02:00
|
|
|
|
2012-12-17 13:36:44 +01:00
|
|
|
ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName));
|
|
|
|
return E_FAIL;
|
2008-09-19 00:43:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static IDispatchExVtbl testObjVtbl = {
|
|
|
|
DispatchEx_QueryInterface,
|
|
|
|
DispatchEx_AddRef,
|
|
|
|
DispatchEx_Release,
|
|
|
|
DispatchEx_GetTypeInfoCount,
|
|
|
|
DispatchEx_GetTypeInfo,
|
|
|
|
DispatchEx_GetIDsOfNames,
|
2019-05-17 16:39:32 +02:00
|
|
|
testObj_Invoke,
|
2009-09-06 19:10:06 +02:00
|
|
|
testObj_GetDispID,
|
2009-09-02 12:25:21 +02:00
|
|
|
testObj_InvokeEx,
|
2008-09-19 00:43:37 +02:00
|
|
|
testObj_DeleteMemberByName,
|
|
|
|
DispatchEx_DeleteMemberByDispID,
|
|
|
|
DispatchEx_GetMemberProperties,
|
|
|
|
DispatchEx_GetMemberName,
|
|
|
|
DispatchEx_GetNextDispID,
|
|
|
|
DispatchEx_GetNameSpaceParent
|
|
|
|
};
|
|
|
|
|
|
|
|
static IDispatchEx testObj = { &testObjVtbl };
|
|
|
|
|
2012-12-24 11:38:28 +01:00
|
|
|
static HRESULT WINAPI dispexFunc_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
|
|
|
|
VARIANT *res, EXCEPINFO *pei, IServiceProvider *pspCaller)
|
|
|
|
{
|
|
|
|
ok(pspCaller != NULL, "pspCaller = NULL\n");
|
|
|
|
|
|
|
|
switch(id) {
|
|
|
|
case DISPID_VALUE:
|
|
|
|
CHECK_EXPECT(dispexfunc_value);
|
|
|
|
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(*pdp->rgdispidNamedArgs == DISPID_THIS, "*rgdispidNamedArgs = %d\n", *pdp->rgdispidNamedArgs);
|
|
|
|
ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(res != NULL, "res == NULL\n");
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
ok(V_VT(pdp->rgvarg+1) == VT_BOOL, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
|
2016-06-15 18:37:13 +02:00
|
|
|
|
|
|
|
if(V_BOOL(pdp->rgvarg+1))
|
|
|
|
/* NOTE: If called by Function.apply(), native doesn't set DISPATCH_PROPERTYGET flag. */
|
|
|
|
todo_wine ok(wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
|
|
|
|
else
|
|
|
|
ok(wFlags == (DISPATCH_PROPERTYGET|DISPATCH_METHOD), "wFlags = %x\n", wFlags);
|
2012-12-24 11:38:28 +01:00
|
|
|
|
|
|
|
ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
|
|
|
|
ok(V_DISPATCH(pdp->rgvarg) != NULL, "V_DISPATCH(pdp->rgvarg) == NULL\n");
|
|
|
|
|
|
|
|
if(res)
|
|
|
|
V_VT(res) = VT_NULL;
|
|
|
|
return S_OK;
|
|
|
|
default:
|
|
|
|
ok(0, "unexpected call %x\n", id);
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDispatchExVtbl dispexFuncVtbl = {
|
|
|
|
DispatchEx_QueryInterface,
|
|
|
|
DispatchEx_AddRef,
|
|
|
|
DispatchEx_Release,
|
|
|
|
DispatchEx_GetTypeInfoCount,
|
|
|
|
DispatchEx_GetTypeInfo,
|
|
|
|
DispatchEx_GetIDsOfNames,
|
|
|
|
DispatchEx_Invoke,
|
|
|
|
DispatchEx_GetDispID,
|
|
|
|
dispexFunc_InvokeEx,
|
|
|
|
DispatchEx_DeleteMemberByName,
|
|
|
|
DispatchEx_DeleteMemberByDispID,
|
|
|
|
DispatchEx_GetMemberProperties,
|
|
|
|
DispatchEx_GetMemberName,
|
|
|
|
DispatchEx_GetNextDispID,
|
|
|
|
DispatchEx_GetNameSpaceParent
|
|
|
|
};
|
|
|
|
|
|
|
|
static IDispatchEx dispexFunc = { &dispexFuncVtbl };
|
|
|
|
|
2011-06-21 17:45:50 +02:00
|
|
|
static HRESULT WINAPI pureDisp_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDispatch)) {
|
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2012-12-24 11:38:28 +01:00
|
|
|
static HRESULT WINAPI pureDisp_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
ok(IsEqualGUID(riid, &IID_NULL), "Expected IID_NULL\n");
|
|
|
|
ok(cNames==1, "cNames = %d\n", cNames);
|
|
|
|
|
|
|
|
if(!strcmp_wa(*rgszNames, "prop")) {
|
|
|
|
CHECK_EXPECT(puredisp_prop_d);
|
|
|
|
*rgDispId = DISPID_TESTOBJ_PROP;
|
|
|
|
return S_OK;
|
|
|
|
} else if(!strcmp_wa(*rgszNames, "noprop")) {
|
|
|
|
CHECK_EXPECT(puredisp_noprop_d);
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI pureDisp_Invoke(IDispatchEx *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
|
|
|
|
WORD wFlags, DISPPARAMS *pdp, VARIANT *res, EXCEPINFO *ei, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
ok(IsEqualGUID(&IID_NULL, riid), "unexpected riid\n");
|
|
|
|
|
|
|
|
switch(dispIdMember) {
|
|
|
|
case DISPID_VALUE:
|
|
|
|
CHECK_EXPECT(puredisp_value);
|
|
|
|
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(res != NULL, "res == NULL\n");
|
|
|
|
ok(ei != NULL, "ei == NULL\n");
|
|
|
|
ok(puArgErr != NULL, "puArgErr == NULL\n");
|
|
|
|
|
|
|
|
ok(V_VT(pdp->rgvarg) == VT_BOOL, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
|
2016-06-15 18:37:13 +02:00
|
|
|
|
|
|
|
if(V_BOOL(pdp->rgvarg))
|
|
|
|
todo_wine ok(wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
|
|
|
|
else
|
|
|
|
ok(wFlags == (DISPATCH_PROPERTYGET|DISPATCH_METHOD), "wFlags = %x\n", wFlags);
|
2012-12-24 11:38:28 +01:00
|
|
|
|
|
|
|
if(res)
|
|
|
|
V_VT(res) = VT_NULL;
|
|
|
|
return S_OK;
|
|
|
|
default:
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-21 17:45:50 +02:00
|
|
|
static IDispatchExVtbl pureDispVtbl = {
|
|
|
|
pureDisp_QueryInterface,
|
|
|
|
DispatchEx_AddRef,
|
|
|
|
DispatchEx_Release,
|
|
|
|
DispatchEx_GetTypeInfoCount,
|
|
|
|
DispatchEx_GetTypeInfo,
|
2012-12-24 11:38:28 +01:00
|
|
|
pureDisp_GetIDsOfNames,
|
|
|
|
pureDisp_Invoke
|
2011-06-21 17:45:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static IDispatchEx pureDisp = { &pureDispVtbl };
|
|
|
|
|
2015-06-02 14:45:20 +02:00
|
|
|
static HRESULT WINAPI BindEventHandler_QueryInterface(IBindEventHandler *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindEventHandler_AddRef(IBindEventHandler *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindEventHandler_Release(IBindEventHandler *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindEventHandler_BindHandler(IBindEventHandler *iface, const WCHAR *event, IDispatch *disp)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(BindHandler);
|
|
|
|
ok(!strcmp_wa(event, "eventName"), "event = %s\n", wine_dbgstr_w(event));
|
|
|
|
ok(disp != NULL, "disp = NULL\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBindEventHandlerVtbl BindEventHandlerVtbl = {
|
|
|
|
BindEventHandler_QueryInterface,
|
|
|
|
BindEventHandler_AddRef,
|
|
|
|
BindEventHandler_Release,
|
|
|
|
BindEventHandler_BindHandler
|
|
|
|
};
|
|
|
|
|
|
|
|
static IBindEventHandler BindEventHandler = { &BindEventHandlerVtbl };
|
|
|
|
|
|
|
|
static HRESULT WINAPI bindEventHandlerDisp_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDispatch) || IsEqualGUID(riid, &IID_IDispatchEx)) {
|
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IBindEventHandler)) {
|
|
|
|
*ppv = &BindEventHandler;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDispatchExVtbl bindEventHandlerDispVtbl = {
|
|
|
|
bindEventHandlerDisp_QueryInterface,
|
|
|
|
DispatchEx_AddRef,
|
|
|
|
DispatchEx_Release,
|
|
|
|
DispatchEx_GetTypeInfoCount,
|
|
|
|
DispatchEx_GetTypeInfo,
|
|
|
|
DispatchEx_GetIDsOfNames,
|
|
|
|
DispatchEx_Invoke,
|
|
|
|
DispatchEx_GetDispID,
|
|
|
|
DispatchEx_InvokeEx,
|
|
|
|
DispatchEx_DeleteMemberByName,
|
|
|
|
DispatchEx_DeleteMemberByDispID,
|
|
|
|
DispatchEx_GetMemberProperties,
|
|
|
|
DispatchEx_GetMemberName,
|
|
|
|
DispatchEx_GetNextDispID,
|
|
|
|
DispatchEx_GetNameSpaceParent
|
|
|
|
};
|
|
|
|
|
|
|
|
static IDispatchEx bindEventHandlerDisp = { &bindEventHandlerDispVtbl };
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
|
|
|
|
{
|
2008-09-09 01:25:23 +02:00
|
|
|
if(!strcmp_wa(bstrName, "ok")) {
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2008-09-09 01:25:23 +02:00
|
|
|
*pid = DISPID_GLOBAL_OK;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if(!strcmp_wa(bstrName, "trace")) {
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2008-09-09 01:25:23 +02:00
|
|
|
*pid = DISPID_GLOBAL_TRACE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-09-09 01:25:05 +02:00
|
|
|
if(!strcmp_wa(bstrName, "reportSuccess")) {
|
|
|
|
CHECK_EXPECT(global_success_d);
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2008-09-09 01:25:05 +02:00
|
|
|
*pid = DISPID_GLOBAL_REPORTSUCCESS;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-09-09 01:22:31 +02:00
|
|
|
if(!strcmp_wa(bstrName, "testPropGet")) {
|
|
|
|
CHECK_EXPECT(global_propget_d);
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2008-09-09 01:22:31 +02:00
|
|
|
*pid = DISPID_GLOBAL_TESTPROPGET;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-09-09 01:24:02 +02:00
|
|
|
if(!strcmp_wa(bstrName, "testPropPut")) {
|
|
|
|
CHECK_EXPECT(global_propput_d);
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2008-09-09 01:24:02 +02:00
|
|
|
*pid = DISPID_GLOBAL_TESTPROPPUT;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2014-11-28 16:18:32 +01:00
|
|
|
if(!strcmp_wa(bstrName, "testPropPutRef")) {
|
|
|
|
CHECK_EXPECT(global_propputref_d);
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_TESTPROPPUTREF;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-12-15 15:42:41 +01:00
|
|
|
if(!strcmp_wa(bstrName, "testPropDelete")) {
|
|
|
|
CHECK_EXPECT(global_propdelete_d);
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_TESTPROPDELETE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-12-17 13:36:55 +01:00
|
|
|
if(!strcmp_wa(bstrName, "testNoPropDelete")) {
|
|
|
|
CHECK_EXPECT(global_nopropdelete_d);
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_TESTNOPROPDELETE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2015-10-15 12:58:38 +02:00
|
|
|
if(!strcmp_wa(bstrName, "testPropDeleteError")) {
|
|
|
|
CHECK_EXPECT(global_propdeleteerror_d);
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_TESTPROPDELETEERROR;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-09-10 21:12:19 +02:00
|
|
|
if(!strcmp_wa(bstrName, "getVT")) {
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2008-09-10 21:12:19 +02:00
|
|
|
*pid = DISPID_GLOBAL_GETVT;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-09-19 00:43:37 +02:00
|
|
|
if(!strcmp_wa(bstrName, "testObj")) {
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2008-09-19 00:43:37 +02:00
|
|
|
*pid = DISPID_GLOBAL_TESTOBJ;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-03-28 15:04:28 +02:00
|
|
|
if(!strcmp_wa(bstrName, "getNullBSTR")) {
|
|
|
|
*pid = DISPID_GLOBAL_GETNULLBSTR;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if(!strcmp_wa(bstrName, "isNullBSTR")) {
|
|
|
|
*pid = DISPID_GLOBAL_ISNULLBSTR;
|
2009-08-05 23:27:31 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2009-09-06 19:09:30 +02:00
|
|
|
if(!strcmp_wa(bstrName, "nullDisp")) {
|
|
|
|
*pid = DISPID_GLOBAL_NULL_DISP;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2009-08-10 12:57:42 +02:00
|
|
|
if(!strcmp_wa(bstrName, "notExists")) {
|
|
|
|
CHECK_EXPECT(global_notexists_d);
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2009-08-10 12:57:42 +02:00
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
2008-09-09 01:22:31 +02:00
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
if(!strcmp_wa(bstrName, "testThis")) {
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2009-09-27 20:59:28 +02:00
|
|
|
*pid = DISPID_GLOBAL_TESTTHIS;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!strcmp_wa(bstrName, "testThis2")) {
|
2009-10-19 20:41:32 +02:00
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2009-09-27 20:59:28 +02:00
|
|
|
*pid = DISPID_GLOBAL_TESTTHIS2;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-19 20:41:32 +02:00
|
|
|
if(!strcmp_wa(bstrName, "invokeVersion")) {
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_INVOKEVERSION;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2010-10-18 18:47:15 +02:00
|
|
|
if(!strcmp_wa(bstrName, "createArray")) {
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
2010-10-19 23:14:35 +02:00
|
|
|
*pid = DISPID_GLOBAL_CREATEARRAY;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if(!strcmp_wa(bstrName, "propGetFunc")) {
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_PROPGETFUNC;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if(!strcmp_wa(bstrName, "objectFlag")) {
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_OBJECT_FLAG;
|
2010-10-18 18:47:15 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2009-10-19 20:41:32 +02:00
|
|
|
|
2010-12-28 15:40:39 +01:00
|
|
|
if(!strcmp_wa(bstrName, "isWin64")) {
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_ISWIN64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-21 17:45:50 +02:00
|
|
|
if(!strcmp_wa(bstrName, "pureDisp")) {
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_PUREDISP;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-04-17 16:26:16 +02:00
|
|
|
if(!strcmp_wa(bstrName, "propArgPutG")) {
|
|
|
|
CHECK_EXPECT(global_propargput_d);
|
|
|
|
test_grfdex(grfdex, fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_PROPARGPUT;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!strcmp_wa(bstrName, "propArgPutO")) {
|
|
|
|
CHECK_EXPECT(global_propargput_d);
|
|
|
|
test_grfdex(grfdex, fdexNameEnsure|fdexNameCaseSensitive);
|
|
|
|
*pid = DISPID_GLOBAL_PROPARGPUT;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-01 15:05:21 +02:00
|
|
|
if(!strcmp_wa(bstrName, "shortProp")) {
|
|
|
|
*pid = DISPID_GLOBAL_SHORTPROP;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!strcmp_wa(bstrName, "getShort")) {
|
|
|
|
*pid = DISPID_GLOBAL_GETSHORT;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!strcmp_wa(bstrName, "testArgTypes")) {
|
|
|
|
*pid = DISPID_GLOBAL_TESTARGTYPES;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-04 15:59:43 +02:00
|
|
|
if(!strcmp_wa(bstrName, "intProp")) {
|
|
|
|
*pid = DISPID_GLOBAL_INTPROP;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:49:42 +01:00
|
|
|
if(!strcmp_wa(bstrName, "dispUnk")) {
|
|
|
|
*pid = DISPID_GLOBAL_DISPUNK;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-13 12:08:34 +01:00
|
|
|
if(!strcmp_wa(bstrName, "testRes")) {
|
|
|
|
*pid = DISPID_GLOBAL_TESTRES;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!strcmp_wa(bstrName, "testNoRes")) {
|
|
|
|
*pid = DISPID_GLOBAL_TESTNORES;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-24 11:38:28 +01:00
|
|
|
if(!strcmp_wa(bstrName, "dispexFunc")) {
|
|
|
|
*pid = DISPID_GLOBAL_DISPEXFUNC;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-01-13 21:46:02 +01:00
|
|
|
if(!strcmp_wa(bstrName, "getScriptState")) {
|
|
|
|
*pid = DISPID_GLOBAL_GETSCRIPTSTATE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-02 14:45:20 +02:00
|
|
|
if(!strcmp_wa(bstrName, "bindEventHandler")) {
|
|
|
|
*pid = DISPID_GLOBAL_BINDEVENTHANDLER;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-17 16:39:32 +02:00
|
|
|
if(!strcmp_wa(bstrName, "testEnumObj")) {
|
|
|
|
*pid = DISPID_GLOBAL_TESTENUMOBJ;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-20 21:05:25 +02:00
|
|
|
if(!strcmp_wa(bstrName, "callEval")) {
|
|
|
|
*pid = DISPID_GLOBAL_CALLEVAL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-04-17 16:26:16 +02:00
|
|
|
if(strict_dispid_check && strcmp_wa(bstrName, "t"))
|
2009-08-19 13:36:31 +02:00
|
|
|
ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName));
|
2008-09-05 02:38:44 +02:00
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
|
|
|
|
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
|
|
|
|
{
|
2012-03-08 14:28:16 +01:00
|
|
|
ok(pspCaller != NULL, "pspCaller = NULL\n");
|
|
|
|
|
2008-09-09 01:25:23 +02:00
|
|
|
switch(id) {
|
|
|
|
case DISPID_GLOBAL_OK:
|
2008-09-17 23:34:05 +02:00
|
|
|
ok(wFlags == INVOKE_FUNC || wFlags == (INVOKE_FUNC|INVOKE_PROPERTYGET), "wFlags = %x\n", wFlags);
|
2008-09-09 01:25:23 +02:00
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
2008-09-17 23:34:05 +02:00
|
|
|
if(wFlags & INVOKE_PROPERTYGET)
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
else
|
|
|
|
ok(!pvarRes, "pvarRes != NULL\n");
|
2008-09-09 01:25:23 +02:00
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
|
|
|
|
ok(V_VT(pdp->rgvarg+1) == VT_BOOL, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
|
2009-08-19 13:36:31 +02:00
|
|
|
ok(V_BOOL(pdp->rgvarg+1), "%s: %s\n", test_name, wine_dbgstr_w(V_BSTR(pdp->rgvarg)));
|
2008-09-09 01:25:23 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
case DISPID_GLOBAL_TRACE:
|
|
|
|
ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(!pvarRes, "pvarRes != NULL\n");
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
|
2008-09-09 01:25:23 +02:00
|
|
|
if(V_VT(pdp->rgvarg) == VT_BSTR)
|
2009-08-19 13:36:31 +02:00
|
|
|
trace("%s: %s\n", test_name, wine_dbgstr_w(V_BSTR(pdp->rgvarg)));
|
2008-09-09 01:25:23 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
case DISPID_GLOBAL_REPORTSUCCESS:
|
|
|
|
CHECK_EXPECT(global_success_i);
|
2008-09-09 01:25:05 +02:00
|
|
|
|
|
|
|
ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
2012-12-12 13:12:39 +01:00
|
|
|
if(!testing_expr)
|
|
|
|
ok(!pvarRes, "pvarRes != NULL\n");
|
2008-09-09 01:25:05 +02:00
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
2008-09-09 01:22:31 +02:00
|
|
|
case DISPID_GLOBAL_TESTPROPGET:
|
|
|
|
CHECK_EXPECT(global_propget_i);
|
|
|
|
|
|
|
|
ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgvarg, "rgvarg != NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_I4;
|
|
|
|
V_I4(pvarRes) = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
2008-09-09 01:24:02 +02:00
|
|
|
|
|
|
|
case DISPID_GLOBAL_TESTPROPPUT:
|
|
|
|
CHECK_EXPECT(global_propput_i);
|
|
|
|
|
|
|
|
ok(wFlags == INVOKE_PROPERTYPUT, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
|
|
|
|
ok(!pvarRes, "pvarRes != NULL\n");
|
|
|
|
|
|
|
|
ok(V_VT(pdp->rgvarg) == VT_I4, "V_VT(pdp->rgvarg)=%d\n", V_VT(pdp->rgvarg));
|
|
|
|
ok(V_I4(pdp->rgvarg) == 1, "V_I4(pdp->rgvarg)=%d\n", V_I4(pdp->rgvarg));
|
|
|
|
return S_OK;
|
2008-09-10 21:12:19 +02:00
|
|
|
|
2014-11-28 16:18:32 +01:00
|
|
|
case DISPID_GLOBAL_TESTPROPPUTREF:
|
|
|
|
CHECK_EXPECT(global_propputref_i);
|
|
|
|
|
|
|
|
ok(wFlags == (INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF), "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
|
|
|
|
ok(!pvarRes, "pvarRes != NULL\n");
|
|
|
|
|
|
|
|
ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg)=%d\n", V_VT(pdp->rgvarg));
|
|
|
|
return S_OK;
|
|
|
|
|
2008-09-10 21:12:19 +02:00
|
|
|
case DISPID_GLOBAL_GETVT:
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_BSTR;
|
|
|
|
switch(V_VT(pdp->rgvarg)) {
|
|
|
|
case VT_EMPTY:
|
|
|
|
V_BSTR(pvarRes) = a2bstr("VT_EMPTY");
|
|
|
|
break;
|
|
|
|
case VT_NULL:
|
|
|
|
V_BSTR(pvarRes) = a2bstr("VT_NULL");
|
|
|
|
break;
|
|
|
|
case VT_I4:
|
|
|
|
V_BSTR(pvarRes) = a2bstr("VT_I4");
|
|
|
|
break;
|
|
|
|
case VT_R8:
|
|
|
|
V_BSTR(pvarRes) = a2bstr("VT_R8");
|
|
|
|
break;
|
|
|
|
case VT_BSTR:
|
|
|
|
V_BSTR(pvarRes) = a2bstr("VT_BSTR");
|
|
|
|
break;
|
|
|
|
case VT_DISPATCH:
|
|
|
|
V_BSTR(pvarRes) = a2bstr("VT_DISPATCH");
|
|
|
|
break;
|
|
|
|
case VT_BOOL:
|
|
|
|
V_BSTR(pvarRes) = a2bstr("VT_BOOL");
|
|
|
|
break;
|
2010-10-19 14:00:14 +02:00
|
|
|
case VT_ARRAY|VT_VARIANT:
|
|
|
|
V_BSTR(pvarRes) = a2bstr("VT_ARRAY|VT_VARIANT");
|
|
|
|
break;
|
2008-09-10 21:12:19 +02:00
|
|
|
default:
|
|
|
|
ok(0, "unknown vt %d\n", V_VT(pdp->rgvarg));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2008-09-19 00:43:37 +02:00
|
|
|
|
2012-12-13 12:08:34 +01:00
|
|
|
case DISPID_GLOBAL_TESTRES:
|
|
|
|
ok(pvarRes != NULL, "pvarRes = NULL\n");
|
2012-12-14 11:06:28 +01:00
|
|
|
if(pvarRes) {
|
|
|
|
V_VT(pvarRes) = VT_BOOL;
|
|
|
|
V_BOOL(pvarRes) = VARIANT_TRUE;
|
|
|
|
}
|
2012-12-13 12:08:34 +01:00
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
case DISPID_GLOBAL_TESTNORES:
|
|
|
|
ok(!pvarRes, "pvarRes != NULL\n");
|
|
|
|
if(pvarRes)
|
|
|
|
V_VT(pvarRes) = VT_NULL;
|
|
|
|
return S_OK;
|
|
|
|
|
2008-09-19 00:43:37 +02:00
|
|
|
case DISPID_GLOBAL_TESTOBJ:
|
|
|
|
ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgvarg, "rgvarg != NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(pvarRes) = (IDispatch*)&testObj;
|
|
|
|
return S_OK;
|
2009-08-05 23:27:31 +02:00
|
|
|
|
2011-06-21 17:45:50 +02:00
|
|
|
case DISPID_GLOBAL_PUREDISP:
|
|
|
|
ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgvarg, "rgvarg != NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(pvarRes) = (IDispatch*)&pureDisp;
|
|
|
|
return S_OK;
|
|
|
|
|
2012-12-24 11:38:28 +01:00
|
|
|
case DISPID_GLOBAL_DISPEXFUNC:
|
|
|
|
V_VT(pvarRes) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(pvarRes) = (IDispatch*)&dispexFunc;
|
|
|
|
return S_OK;
|
|
|
|
|
2012-03-28 15:04:28 +02:00
|
|
|
case DISPID_GLOBAL_GETNULLBSTR:
|
2009-08-05 23:27:31 +02:00
|
|
|
if(pvarRes) {
|
|
|
|
V_VT(pvarRes) = VT_BSTR;
|
|
|
|
V_BSTR(pvarRes) = NULL;
|
|
|
|
}
|
|
|
|
return S_OK;
|
2009-09-06 19:09:30 +02:00
|
|
|
|
2012-03-28 15:04:28 +02:00
|
|
|
case DISPID_GLOBAL_ISNULLBSTR:
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_BOOL;
|
|
|
|
V_BOOL(pvarRes) = V_BSTR(pdp->rgvarg) ? VARIANT_FALSE : VARIANT_TRUE;
|
|
|
|
return S_OK;
|
|
|
|
|
2010-12-28 15:40:39 +01:00
|
|
|
case DISPID_GLOBAL_ISWIN64:
|
|
|
|
if(pvarRes) {
|
|
|
|
V_VT(pvarRes) = VT_BOOL;
|
2011-01-02 15:06:41 +01:00
|
|
|
V_BOOL(pvarRes) = sizeof(void*) == 8 ? VARIANT_TRUE : VARIANT_FALSE;
|
2010-12-28 15:40:39 +01:00
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
|
2009-09-06 19:09:30 +02:00
|
|
|
case DISPID_GLOBAL_NULL_DISP:
|
|
|
|
ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgvarg, "rgvarg != NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(pvarRes) = NULL;
|
|
|
|
return S_OK;
|
2009-09-27 20:59:28 +02:00
|
|
|
|
|
|
|
case DISPID_GLOBAL_TESTTHIS:
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes == NULL, "pvarRes != NULL\n");
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
|
2009-09-27 20:59:28 +02:00
|
|
|
ok(V_DISPATCH(pdp->rgvarg) == (IDispatch*)iface, "disp != iface\n");
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
case DISPID_GLOBAL_TESTTHIS2:
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes == NULL, "pvarRes != NULL\n");
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(arg) = %d\n", V_VT(pdp->rgvarg));
|
|
|
|
ok(V_DISPATCH(pdp->rgvarg) != (IDispatch*)iface, "disp == iface\n");
|
|
|
|
ok(V_DISPATCH(pdp->rgvarg) == script_disp, "disp != script_disp\n");
|
|
|
|
|
|
|
|
return S_OK;
|
2009-10-19 20:41:32 +02:00
|
|
|
|
|
|
|
case DISPID_GLOBAL_INVOKEVERSION:
|
|
|
|
ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgvarg, "rgvarg != NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_I4;
|
|
|
|
V_I4(pvarRes) = invoke_version;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
2010-10-19 23:14:35 +02:00
|
|
|
case DISPID_GLOBAL_CREATEARRAY: {
|
2010-10-18 18:47:15 +02:00
|
|
|
SAFEARRAYBOUND bound[2];
|
|
|
|
VARIANT *data;
|
|
|
|
int i,j;
|
|
|
|
|
|
|
|
ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
2011-12-07 11:00:20 +01:00
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
2010-10-18 18:47:15 +02:00
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes != NULL, "pvarRes == NULL\n");
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
bound[0].lLbound = 0;
|
|
|
|
bound[0].cElements = 5;
|
|
|
|
bound[1].lLbound = 2;
|
|
|
|
bound[1].cElements = 2;
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_ARRAY|VT_VARIANT;
|
|
|
|
V_ARRAY(pvarRes) = SafeArrayCreate(VT_VARIANT, 2, bound);
|
|
|
|
|
|
|
|
SafeArrayAccessData(V_ARRAY(pvarRes), (void**)&data);
|
|
|
|
for(i=0; i<5; i++) {
|
|
|
|
for(j=2; j<4; j++) {
|
|
|
|
V_VT(data) = VT_I4;
|
|
|
|
V_I4(data) = i*10+j;
|
|
|
|
data++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(pvarRes));
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2010-10-19 23:14:35 +02:00
|
|
|
|
|
|
|
case DISPID_GLOBAL_PROPGETFUNC:
|
|
|
|
switch(wFlags) {
|
|
|
|
case INVOKE_FUNC:
|
|
|
|
CHECK_EXPECT(invoke_func);
|
|
|
|
break;
|
|
|
|
case INVOKE_FUNC|INVOKE_PROPERTYGET:
|
|
|
|
ok(pdp->cArgs != 0, "pdp->cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(pvarRes != NULL, "pdp->pvarRes == NULL\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ok(0, "invalid flag (%x)\n", wFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
if(pvarRes) {
|
|
|
|
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
V_VT(pvarRes) = VT_I4;
|
|
|
|
V_I4(pvarRes) = pdp->cArgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
2015-01-13 21:46:02 +01:00
|
|
|
case DISPID_GLOBAL_GETSCRIPTSTATE: {
|
|
|
|
SCRIPTSTATE state;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IActiveScript_GetScriptState(script_engine, &state);
|
|
|
|
ok(hres == S_OK, "GetScriptState failed: %08x\n", hres);
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_I4;
|
|
|
|
V_I4(pvarRes) = state;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-02 14:45:20 +02:00
|
|
|
case DISPID_GLOBAL_BINDEVENTHANDLER:
|
|
|
|
V_VT(pvarRes) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(pvarRes) = (IDispatch*)&bindEventHandlerDisp;
|
|
|
|
return S_OK;
|
|
|
|
|
2012-04-17 16:26:16 +02:00
|
|
|
case DISPID_GLOBAL_PROPARGPUT:
|
|
|
|
CHECK_EXPECT(global_propargput_i);
|
|
|
|
ok(wFlags == INVOKE_PROPERTYPUT, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg != NULL\n");
|
|
|
|
ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
|
|
|
|
ok(pdp->cArgs == 3, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
|
|
|
|
ok(!pvarRes, "pvarRes != NULL\n");
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg) == VT_I4, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
|
|
|
|
ok(V_I4(pdp->rgvarg) == 2, "V_I4(pdp->rgvarg) = %d\n", V_I4(pdp->rgvarg));
|
2012-04-17 16:26:16 +02:00
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
|
|
|
|
ok(V_I4(pdp->rgvarg+1) == 1, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp->rgvarg+1));
|
2012-04-17 16:26:16 +02:00
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg+2) == VT_I4, "V_VT(pdp->rgvarg+2) = %d\n", V_VT(pdp->rgvarg+2));
|
|
|
|
ok(V_I4(pdp->rgvarg+2) == 0, "V_I4(pdp->rgvarg+2) = %d\n", V_I4(pdp->rgvarg+2));
|
2012-04-17 16:26:16 +02:00
|
|
|
return S_OK;
|
|
|
|
|
2010-10-19 23:14:35 +02:00
|
|
|
case DISPID_GLOBAL_OBJECT_FLAG: {
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IDispatch_QueryInterface(script_disp, &IID_IDispatchEx, (void**)&dispex);
|
|
|
|
ok(hres == S_OK, "hres = %x\n", hres);
|
|
|
|
|
|
|
|
str = a2bstr("Object");
|
|
|
|
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
|
|
|
|
SysFreeString(str);
|
|
|
|
ok(hres == S_OK, "hres = %x\n", hres);
|
|
|
|
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_METHOD, pdp, NULL, pei, pspCaller);
|
|
|
|
ok(hres == S_OK, "hres = %x\n", hres);
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_EMPTY;
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_METHOD, pdp, pvarRes, pei, pspCaller);
|
|
|
|
ok(hres == S_OK, "hres = %x\n", hres);
|
|
|
|
ok(V_VT(pvarRes) == VT_DISPATCH, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
VariantClear(pvarRes);
|
|
|
|
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_METHOD|DISPATCH_PROPERTYGET, pdp, NULL, pei, pspCaller);
|
|
|
|
ok(hres == S_OK, "hres = %x\n", hres);
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_EMPTY;
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_CONSTRUCT, pdp, pvarRes, pei, pspCaller);
|
|
|
|
ok(hres == S_OK, "hres = %x\n", hres);
|
|
|
|
ok(V_VT(pvarRes) == VT_DISPATCH, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
VariantClear(pvarRes);
|
|
|
|
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_CONSTRUCT, pdp, NULL, pei, pspCaller);
|
|
|
|
ok(hres == S_OK, "hres = %x\n", hres);
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_EMPTY;
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_CONSTRUCT|DISPATCH_PROPERTYGET, pdp, pvarRes, pei, pspCaller);
|
|
|
|
ok(hres == E_INVALIDARG, "hres = %x\n", hres);
|
|
|
|
|
|
|
|
V_VT(pvarRes) = VT_EMPTY;
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
|
|
|
|
ok(hres == S_OK, "hres = %x\n", hres);
|
|
|
|
ok(V_VT(pvarRes) == VT_DISPATCH, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-05-01 15:05:21 +02:00
|
|
|
case DISPID_GLOBAL_SHORTPROP:
|
|
|
|
case DISPID_GLOBAL_GETSHORT:
|
|
|
|
V_VT(pvarRes) = VT_I2;
|
|
|
|
V_I2(pvarRes) = 10;
|
|
|
|
return S_OK;
|
|
|
|
|
2012-05-04 15:59:43 +02:00
|
|
|
case DISPID_GLOBAL_INTPROP:
|
|
|
|
V_VT(pvarRes) = VT_INT;
|
|
|
|
V_INT(pvarRes) = 22;
|
|
|
|
return S_OK;
|
|
|
|
|
2012-12-05 14:49:42 +01:00
|
|
|
case DISPID_GLOBAL_DISPUNK:
|
|
|
|
V_VT(pvarRes) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(pvarRes) = (IUnknown*)&testObj;
|
|
|
|
return S_OK;
|
|
|
|
|
2012-05-01 15:05:21 +02:00
|
|
|
case DISPID_GLOBAL_TESTARGTYPES: {
|
2017-11-01 16:43:37 +01:00
|
|
|
VARIANT args[8], v;
|
2018-06-05 20:09:44 +02:00
|
|
|
DISPPARAMS dp = {args, NULL, ARRAY_SIZE(args), 0};
|
2012-05-01 15:05:21 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
CHECK_EXPECT(global_testargtypes_i);
|
|
|
|
ok(wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg != NULL\n");
|
2012-12-05 14:49:42 +01:00
|
|
|
ok(pdp->cArgs == 6, "cArgs = %d\n", pdp->cArgs);
|
2012-05-01 15:05:21 +02:00
|
|
|
ok(!pvarRes, "pvarRes != NULL\n");
|
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
|
|
|
|
ok(V_I4(pdp->rgvarg+1) == 10, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp->rgvarg+1));
|
2012-05-01 15:05:21 +02:00
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg+2) == VT_I4, "V_VT(pdp->rgvarg+2) = %d\n", V_VT(pdp->rgvarg+2));
|
|
|
|
ok(V_I4(pdp->rgvarg+2) == 10, "V_I4(pdp->rgvarg+2) = %d\n", V_I4(pdp->rgvarg+2));
|
2012-05-01 15:05:21 +02:00
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg+3) == VT_I4, "V_VT(pdp->rgvarg+3) = %d\n", V_VT(pdp->rgvarg+3));
|
|
|
|
ok(V_I4(pdp->rgvarg+3) == 22, "V_I4(pdp->rgvarg+3) = %d\n", V_I4(pdp->rgvarg+3));
|
2012-05-04 15:59:43 +02:00
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg+4) == VT_I4, "V_VT(pdp->rgvarg+4) = %d\n", V_VT(pdp->rgvarg+4));
|
|
|
|
ok(V_I4(pdp->rgvarg+4) == 22, "V_I4(pdp->rgvarg+4) = %d\n", V_I4(pdp->rgvarg+4));
|
2012-05-04 15:59:43 +02:00
|
|
|
|
2012-12-05 14:49:42 +01:00
|
|
|
ok(V_VT(pdp->rgvarg+5) == VT_DISPATCH, "V_VT(pdp->rgvarg+5) = %d\n", V_VT(pdp->rgvarg+5));
|
|
|
|
ok(V_DISPATCH(pdp->rgvarg+5) == (IDispatch*)&testObj, "V_DISPATCH(pdp->rgvarg+5) != testObj\n");
|
|
|
|
|
2012-06-15 23:23:55 +02:00
|
|
|
ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
|
2012-05-01 15:05:21 +02:00
|
|
|
|
|
|
|
V_VT(args) = VT_I2;
|
|
|
|
V_I2(args) = 2;
|
2012-05-04 15:59:43 +02:00
|
|
|
V_VT(args+1) = VT_INT;
|
|
|
|
V_INT(args+1) = 22;
|
2012-12-05 14:49:42 +01:00
|
|
|
V_VT(args+2) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(args+2) = (IUnknown*)&testObj;
|
2014-03-19 13:15:14 +01:00
|
|
|
V_VT(args+3) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(args+3) = NULL;
|
2015-02-03 19:37:07 +01:00
|
|
|
V_VT(args+4) = VT_UI4;
|
|
|
|
V_UI4(args+4) = 0xffffffff;
|
2015-02-06 12:10:00 +01:00
|
|
|
V_VT(args+5) = VT_BYREF|VT_VARIANT;
|
|
|
|
V_VARIANTREF(args+5) = &v;
|
2017-08-21 21:34:39 +02:00
|
|
|
V_VT(args+6) = VT_R4;
|
|
|
|
V_R4(args+6) = 0.5;
|
2017-11-01 16:43:37 +01:00
|
|
|
V_VT(args+7) = VT_UI2;
|
|
|
|
V_R4(args+7) = 3;
|
2015-02-06 12:10:00 +01:00
|
|
|
V_VT(&v) = VT_I4;
|
|
|
|
V_I4(&v) = 2;
|
2012-05-01 15:05:21 +02:00
|
|
|
hres = IDispatch_Invoke(V_DISPATCH(pdp->rgvarg), DISPID_VALUE, &IID_NULL, 0, DISPATCH_METHOD, &dp, NULL, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "Invoke failed: %08x\n", hres);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2019-05-20 21:05:25 +02:00
|
|
|
|
|
|
|
case DISPID_GLOBAL_CALLEVAL: {
|
|
|
|
IDispatchEx *eval_func;
|
|
|
|
DISPPARAMS params;
|
|
|
|
VARIANT arg, res;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
CHECK_EXPECT(global_calleval_i);
|
|
|
|
|
|
|
|
ok(pdp != NULL, "pdp == NULL\n");
|
|
|
|
ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
|
|
|
|
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
|
|
|
|
ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
|
|
|
|
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
|
|
|
|
ok(pvarRes == NULL, "pvarRes != NULL\n");
|
|
|
|
ok(pei != NULL, "pei == NULL\n");
|
|
|
|
|
|
|
|
ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(arg) = %d\n", V_VT(pdp->rgvarg));
|
|
|
|
hres = IDispatch_QueryInterface(V_DISPATCH(pdp->rgvarg), &IID_IDispatchEx, (void**)&eval_func);
|
|
|
|
ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
|
|
|
|
|
|
|
|
params.rgvarg = &arg;
|
|
|
|
params.rgdispidNamedArgs = NULL;
|
|
|
|
params.cArgs = 1;
|
|
|
|
params.cNamedArgs = 0;
|
|
|
|
V_VT(&arg) = VT_BSTR;
|
|
|
|
|
|
|
|
V_BSTR(&arg) = a2bstr("var x = 5; v");
|
|
|
|
V_VT(&res) = VT_ERROR;
|
|
|
|
hres = IDispatchEx_InvokeEx(eval_func, DISPID_VALUE, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res));
|
|
|
|
ok(V_I4(&res) == 2, "eval returned %d\n", V_I4(&res));
|
|
|
|
SysFreeString(V_BSTR(&arg));
|
|
|
|
IDispatchEx_Release(eval_func);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-09-19 00:43:37 +02:00
|
|
|
}
|
2008-09-09 01:22:31 +02:00
|
|
|
|
2008-09-09 01:25:23 +02:00
|
|
|
ok(0, "unexpected call %x\n", id);
|
2008-09-05 02:38:44 +02:00
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
|
2011-12-15 15:42:41 +01:00
|
|
|
static HRESULT WINAPI Global_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
|
|
|
|
{
|
2012-12-17 13:36:55 +01:00
|
|
|
switch(id) {
|
|
|
|
case DISPID_GLOBAL_TESTPROPDELETE:
|
|
|
|
CHECK_EXPECT(DeleteMemberByDispID);
|
|
|
|
return S_OK;
|
|
|
|
case DISPID_GLOBAL_TESTNOPROPDELETE:
|
|
|
|
CHECK_EXPECT(DeleteMemberByDispID_false);
|
|
|
|
return S_FALSE;
|
2015-10-15 12:58:38 +02:00
|
|
|
case DISPID_GLOBAL_TESTPROPDELETEERROR:
|
|
|
|
CHECK_EXPECT(DeleteMemberByDispID_error);
|
|
|
|
return E_FAIL;
|
2012-12-17 13:36:55 +01:00
|
|
|
default:
|
|
|
|
ok(0, "id = %d\n", id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_FAIL;
|
2011-12-15 15:42:41 +01:00
|
|
|
}
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
static IDispatchExVtbl GlobalVtbl = {
|
|
|
|
DispatchEx_QueryInterface,
|
|
|
|
DispatchEx_AddRef,
|
|
|
|
DispatchEx_Release,
|
|
|
|
DispatchEx_GetTypeInfoCount,
|
|
|
|
DispatchEx_GetTypeInfo,
|
|
|
|
DispatchEx_GetIDsOfNames,
|
|
|
|
DispatchEx_Invoke,
|
|
|
|
Global_GetDispID,
|
|
|
|
Global_InvokeEx,
|
|
|
|
DispatchEx_DeleteMemberByName,
|
2011-12-15 15:42:41 +01:00
|
|
|
Global_DeleteMemberByDispID,
|
2008-09-05 02:38:44 +02:00
|
|
|
DispatchEx_GetMemberProperties,
|
|
|
|
DispatchEx_GetMemberName,
|
|
|
|
DispatchEx_GetNextDispID,
|
|
|
|
DispatchEx_GetNameSpaceParent
|
|
|
|
};
|
|
|
|
|
|
|
|
static IDispatchEx Global = { &GlobalVtbl };
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
*plcid = GetUserDefaultLCID();
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR pstrName,
|
|
|
|
DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti)
|
|
|
|
{
|
|
|
|
ok(dwReturnMask == SCRIPTINFO_IUNKNOWN, "unexpected dwReturnMask %x\n", dwReturnMask);
|
|
|
|
ok(!ppti, "ppti != NULL\n");
|
|
|
|
|
2008-12-16 16:42:50 +01:00
|
|
|
if(!strcmp_wa(pstrName, test_valA))
|
2008-12-15 22:24:33 +01:00
|
|
|
CHECK_EXPECT(GetItemInfo_testVal);
|
2008-12-16 16:42:50 +01:00
|
|
|
else if(strcmp_wa(pstrName, testA))
|
2009-08-19 13:36:31 +02:00
|
|
|
ok(0, "unexpected pstrName %s\n", wine_dbgstr_w(pstrName));
|
2008-12-15 22:24:33 +01:00
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
*ppiunkItem = (IUnknown*)&Global;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface,
|
|
|
|
const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef ACTSCPSITE_THIS
|
|
|
|
|
|
|
|
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 };
|
|
|
|
|
2010-10-09 16:43:48 +02:00
|
|
|
static HRESULT WINAPI ActiveScriptSite_OnScriptError_CheckError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
|
|
|
|
{
|
|
|
|
ok(pscripterror != NULL, "ActiveScriptSite_OnScriptError -- expected pscripterror to be set, got NULL\n");
|
|
|
|
|
|
|
|
script_error = pscripterror;
|
2012-07-30 12:02:01 +02:00
|
|
|
IActiveScriptError_AddRef(script_error);
|
2010-10-09 16:43:48 +02:00
|
|
|
|
|
|
|
CHECK_EXPECT(ActiveScriptSite_OnScriptError);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IActiveScriptSiteVtbl ActiveScriptSite_CheckErrorVtbl = {
|
|
|
|
ActiveScriptSite_QueryInterface,
|
|
|
|
ActiveScriptSite_AddRef,
|
|
|
|
ActiveScriptSite_Release,
|
|
|
|
ActiveScriptSite_GetLCID,
|
|
|
|
ActiveScriptSite_GetItemInfo,
|
|
|
|
ActiveScriptSite_GetDocVersionString,
|
|
|
|
ActiveScriptSite_OnScriptTerminate,
|
|
|
|
ActiveScriptSite_OnStateChange,
|
|
|
|
ActiveScriptSite_OnScriptError_CheckError,
|
|
|
|
ActiveScriptSite_OnEnterScript,
|
|
|
|
ActiveScriptSite_OnLeaveScript
|
|
|
|
};
|
|
|
|
|
|
|
|
static IActiveScriptSite ActiveScriptSite_CheckError = { &ActiveScriptSite_CheckErrorVtbl };
|
|
|
|
|
2009-10-19 20:41:32 +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);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptProperty iface: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScriptProperty_SetProperty(script_prop, property, NULL, val);
|
|
|
|
IActiveScriptProperty_Release(script_prop);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
static IActiveScript *create_script(void)
|
|
|
|
{
|
|
|
|
IActiveScript *script;
|
2009-10-19 20:41:32 +02:00
|
|
|
VARIANT v;
|
2008-09-05 02:38:44 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2012-03-26 11:43:23 +02:00
|
|
|
hres = CoCreateInstance(engine_clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
2008-09-05 02:38:44 +02:00
|
|
|
&IID_IActiveScript, (void**)&script);
|
|
|
|
ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
|
|
|
|
|
2009-10-19 20:41:32 +02:00
|
|
|
V_VT(&v) = VT_I4;
|
|
|
|
V_I4(&v) = invoke_version;
|
|
|
|
hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
|
|
|
|
ok(hres == S_OK || broken(hres == E_NOTIMPL), "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres);
|
|
|
|
if(invoke_version && FAILED(hres)) {
|
|
|
|
IActiveScript_Release(script);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
return script;
|
|
|
|
}
|
|
|
|
|
2010-01-23 23:58:23 +01:00
|
|
|
static HRESULT parse_script(DWORD flags, BSTR script_str)
|
2008-09-05 02:38:44 +02:00
|
|
|
{
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *engine;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
engine = create_script();
|
|
|
|
if(!engine)
|
2010-01-23 23:58:23 +01:00
|
|
|
return S_OK;
|
2008-09-05 02:38:44 +02:00
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
2009-01-05 15:50:36 +01:00
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
IActiveScript_Release(engine);
|
2010-01-23 23:58:23 +01:00
|
|
|
return hres;
|
2009-01-05 15:50:36 +01:00
|
|
|
}
|
2008-09-05 02:38:44 +02:00
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
2008-09-05 02:38:44 +02:00
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_AddNamedItem(engine, testW,
|
2009-09-27 20:59:28 +02:00
|
|
|
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|flags);
|
2008-09-05 02:38:44 +02:00
|
|
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
2008-10-02 16:24:02 +02:00
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
2008-09-05 02:38:44 +02:00
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
hres = IActiveScript_GetScriptDispatch(engine, NULL, &script_disp);
|
|
|
|
ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
|
|
|
|
ok(script_disp != NULL, "script_disp == NULL\n");
|
|
|
|
ok(script_disp != (IDispatch*)&Global, "script_disp == Global\n");
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, script_str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
2008-09-05 02:38:44 +02:00
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
IDispatch_Release(script_disp);
|
2008-09-05 02:38:44 +02:00
|
|
|
IActiveScript_Release(engine);
|
2012-07-30 12:02:01 +02:00
|
|
|
IActiveScriptParse_Release(parser);
|
2010-01-23 23:58:23 +01:00
|
|
|
|
|
|
|
return hres;
|
2008-09-05 02:38:44 +02:00
|
|
|
}
|
|
|
|
|
2012-10-04 14:57:46 +02:00
|
|
|
static HRESULT invoke_procedure(const char *argsa, const char *sourcea, DISPPARAMS *dp)
|
|
|
|
{
|
|
|
|
IActiveScriptParseProcedure2 *parse_proc;
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *engine;
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
EXCEPINFO ei = {0};
|
|
|
|
BSTR source, args;
|
|
|
|
IDispatch *disp;
|
|
|
|
VARIANT res;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
engine = create_script();
|
|
|
|
if(!engine)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParseProcedure2, (void**)&parse_proc);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
|
|
|
|
source = a2bstr(sourcea);
|
|
|
|
args = argsa ? a2bstr(argsa) : NULL;
|
|
|
|
hres = IActiveScriptParseProcedure2_ParseProcedureText(parse_proc, source, args, emptyW, NULL, NULL, NULL, 0, 0,
|
|
|
|
SCRIPTPROC_HOSTMANAGESSOURCE|SCRIPTPROC_IMPLICIT_THIS|SCRIPTPROC_IMPLICIT_PARENTS, &disp);
|
|
|
|
ok(hres == S_OK, "ParseProcedureText failed: %08x\n", hres);
|
|
|
|
SysFreeString(source);
|
|
|
|
SysFreeString(args);
|
|
|
|
|
|
|
|
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
|
|
|
|
ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
|
|
|
|
IDispatch_Release(disp);
|
|
|
|
|
|
|
|
V_VT(&res) = VT_EMPTY;
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_METHOD, dp, &res, &ei, NULL);
|
|
|
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&res) == VT_BOOL && V_BOOL(&res), "InvokeEx returned vt %d (%x)\n", V_VT(&res), V_I4(&res));
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
|
|
|
IActiveScriptParseProcedure2_Release(parse_proc);
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
IActiveScriptParse_Release(parser);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2009-04-09 23:34:56 +02:00
|
|
|
static HRESULT parse_htmlscript(BSTR script_str)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *engine;
|
|
|
|
HRESULT hres;
|
|
|
|
BSTR tmp = a2bstr("</SCRIPT>");
|
|
|
|
|
|
|
|
engine = create_script();
|
|
|
|
if(!engine)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
2009-04-09 23:34:56 +02:00
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_AddNamedItem(engine, testW,
|
|
|
|
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
|
|
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, script_str, NULL, NULL, tmp, 0, 0, 0, NULL, NULL);
|
2009-04-09 23:34:56 +02:00
|
|
|
|
|
|
|
IActiveScript_Release(engine);
|
2012-07-30 12:02:01 +02:00
|
|
|
IActiveScriptParse_Release(parser);
|
2009-04-09 23:34:56 +02:00
|
|
|
SysFreeString(tmp);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2010-10-09 16:43:48 +02:00
|
|
|
static void test_IActiveScriptError(IActiveScriptError *error, SCODE errorcode, ULONG line, LONG pos, BSTR script_source, BSTR description, BSTR line_text)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
DWORD source_context;
|
|
|
|
ULONG line_number;
|
|
|
|
LONG char_position;
|
|
|
|
BSTR linetext;
|
|
|
|
EXCEPINFO excep;
|
|
|
|
|
|
|
|
/* IActiveScriptError_GetSourcePosition */
|
|
|
|
|
|
|
|
hres = IActiveScriptError_GetSourcePosition(error, NULL, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "IActiveScriptError_GetSourcePosition -- hres: expected S_OK, got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
source_context = 0xdeadbeef;
|
|
|
|
hres = IActiveScriptError_GetSourcePosition(error, &source_context, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "IActiveScriptError_GetSourcePosition -- hres: expected S_OK, got 0x%08x\n", hres);
|
|
|
|
ok(source_context == 0, "IActiveScriptError_GetSourcePosition -- source_context: expected 0, got 0x%08x\n", source_context);
|
|
|
|
|
|
|
|
line_number = 0xdeadbeef;
|
|
|
|
hres = IActiveScriptError_GetSourcePosition(error, NULL, &line_number, NULL);
|
|
|
|
ok(hres == S_OK, "IActiveScriptError_GetSourcePosition -- hres: expected S_OK, got 0x%08x\n", hres);
|
|
|
|
ok(line_number == line, "IActiveScriptError_GetSourcePosition -- line_number: expected %d, got %d\n", line, line_number);
|
|
|
|
|
|
|
|
char_position = 0xdeadbeef;
|
|
|
|
hres = IActiveScriptError_GetSourcePosition(error, NULL, NULL, &char_position);
|
|
|
|
ok(hres == S_OK, "IActiveScriptError_GetSourcePosition -- hres: expected S_OK, got 0x%08x\n", hres);
|
|
|
|
ok(char_position == pos, "IActiveScriptError_GetSourcePosition -- char_position: expected %d, got %d\n", pos, char_position);
|
|
|
|
|
|
|
|
/* IActiveScriptError_GetSourceLineText */
|
|
|
|
|
|
|
|
hres = IActiveScriptError_GetSourceLineText(error, NULL);
|
|
|
|
ok(hres == E_POINTER, "IActiveScriptError_GetSourceLineText -- hres: expected E_POINTER, got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
linetext = NULL;
|
|
|
|
hres = IActiveScriptError_GetSourceLineText(error, &linetext);
|
|
|
|
if (line_text) {
|
|
|
|
ok(hres == S_OK, "IActiveScriptError_GetSourceLineText -- hres: expected S_OK, got 0x%08x\n", hres);
|
|
|
|
ok(linetext != NULL && !lstrcmpW(linetext, line_text),
|
|
|
|
"IActiveScriptError_GetSourceLineText -- expected %s, got %s\n", wine_dbgstr_w(line_text), wine_dbgstr_w(linetext));
|
|
|
|
} else {
|
|
|
|
ok(hres == E_FAIL, "IActiveScriptError_GetSourceLineText -- hres: expected S_OK, got 0x%08x\n", hres);
|
|
|
|
ok(linetext == NULL,
|
|
|
|
"IActiveScriptError_GetSourceLineText -- expected NULL, got %s\n", wine_dbgstr_w(linetext));
|
|
|
|
}
|
|
|
|
SysFreeString(linetext);
|
|
|
|
|
|
|
|
/* IActiveScriptError_GetExceptionInfo */
|
|
|
|
|
|
|
|
hres = IActiveScriptError_GetExceptionInfo(error, NULL);
|
|
|
|
ok(hres == E_POINTER, "IActiveScriptError_GetExceptionInfo -- hres: expected E_POINTER, got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
excep.wCode = 0xdead;
|
|
|
|
excep.wReserved = 0xdead;
|
|
|
|
excep.bstrSource = (BSTR)0xdeadbeef;
|
|
|
|
excep.bstrDescription = (BSTR)0xdeadbeef;
|
|
|
|
excep.bstrHelpFile = (BSTR)0xdeadbeef;
|
|
|
|
excep.dwHelpContext = 0xdeadbeef;
|
|
|
|
excep.pvReserved = (void *)0xdeadbeef;
|
|
|
|
excep.pfnDeferredFillIn = (void *)0xdeadbeef;
|
|
|
|
excep.scode = 0xdeadbeef;
|
|
|
|
|
|
|
|
hres = IActiveScriptError_GetExceptionInfo(error, &excep);
|
|
|
|
ok(hres == S_OK, "IActiveScriptError_GetExceptionInfo -- hres: expected S_OK, got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
ok(excep.wCode == 0, "IActiveScriptError_GetExceptionInfo -- excep.wCode: expected 0, got 0x%08x\n", excep.wCode);
|
|
|
|
ok(excep.wReserved == 0, "IActiveScriptError_GetExceptionInfo -- excep.wReserved: expected 0, got %d\n", excep.wReserved);
|
2011-09-18 19:38:18 +02:00
|
|
|
if (!is_lang_english())
|
|
|
|
skip("Non-english UI (test with hardcoded strings)\n");
|
2010-10-09 16:43:48 +02:00
|
|
|
else {
|
|
|
|
ok(excep.bstrSource != NULL && !lstrcmpW(excep.bstrSource, script_source),
|
|
|
|
"IActiveScriptError_GetExceptionInfo -- excep.bstrSource is not valid: expected %s, got %s\n",
|
|
|
|
wine_dbgstr_w(script_source), wine_dbgstr_w(excep.bstrSource));
|
|
|
|
ok(excep.bstrDescription != NULL && !lstrcmpW(excep.bstrDescription, description),
|
|
|
|
"IActiveScriptError_GetExceptionInfo -- excep.bstrDescription is not valid: got %s\n", wine_dbgstr_w(excep.bstrDescription));
|
|
|
|
}
|
|
|
|
ok(excep.bstrHelpFile == NULL,
|
|
|
|
"IActiveScriptError_GetExceptionInfo -- excep.bstrHelpFile: expected NULL, got %s\n", wine_dbgstr_w(excep.bstrHelpFile));
|
|
|
|
ok(excep.dwHelpContext == 0, "IActiveScriptError_GetExceptionInfo -- excep.dwHelpContext: expected 0, got %d\n", excep.dwHelpContext);
|
|
|
|
ok(excep.pvReserved == NULL, "IActiveScriptError_GetExceptionInfo -- excep.pvReserved: expected NULL, got %p\n", excep.pvReserved);
|
|
|
|
ok(excep.pfnDeferredFillIn == NULL, "IActiveScriptError_GetExceptionInfo -- excep.pfnDeferredFillIn: expected NULL, got %p\n", excep.pfnDeferredFillIn);
|
|
|
|
ok(excep.scode == errorcode, "IActiveScriptError_GetExceptionInfo -- excep.scode: expected 0x%08x, got 0x%08x\n", errorcode, excep.scode);
|
|
|
|
|
|
|
|
SysFreeString(excep.bstrSource);
|
|
|
|
SysFreeString(excep.bstrDescription);
|
|
|
|
SysFreeString(excep.bstrHelpFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void parse_script_with_error(DWORD flags, BSTR script_str, SCODE errorcode, ULONG line, LONG pos, BSTR script_source, BSTR description, BSTR line_text)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *engine;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
engine = create_script();
|
|
|
|
if(!engine)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
2010-10-09 16:43:48 +02:00
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite_CheckError);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_AddNamedItem(engine, testW,
|
|
|
|
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|flags);
|
|
|
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_GetScriptDispatch(engine, NULL, &script_disp);
|
|
|
|
ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
|
|
|
|
ok(script_disp != NULL, "script_disp == NULL\n");
|
|
|
|
ok(script_disp != (IDispatch*)&Global, "script_disp == Global\n");
|
|
|
|
|
|
|
|
script_error = NULL;
|
|
|
|
SET_EXPECT(ActiveScriptSite_OnScriptError);
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, script_str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
2010-10-09 16:43:48 +02:00
|
|
|
todo_wine ok(hres == 0x80020101, "parse_script_with_error should have returned 0x80020101, got: 0x%08x\n", hres);
|
|
|
|
todo_wine CHECK_CALLED(ActiveScriptSite_OnScriptError);
|
|
|
|
|
|
|
|
if (script_error)
|
|
|
|
{
|
|
|
|
test_IActiveScriptError(script_error, errorcode, line, pos, script_source, description, line_text);
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
IActiveScriptError_Release(script_error);
|
2010-10-09 16:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IDispatch_Release(script_disp);
|
|
|
|
IActiveScript_Release(engine);
|
2012-07-30 12:02:01 +02:00
|
|
|
IActiveScriptParse_Release(parser);
|
2010-10-09 16:43:48 +02:00
|
|
|
}
|
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
static void parse_script_af(DWORD flags, const char *src)
|
2008-09-05 02:38:44 +02:00
|
|
|
{
|
2010-01-23 23:58:23 +01:00
|
|
|
BSTR tmp;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
tmp = a2bstr(src);
|
|
|
|
hres = parse_script(flags, tmp);
|
2008-09-05 02:38:44 +02:00
|
|
|
SysFreeString(tmp);
|
2010-01-23 23:58:23 +01:00
|
|
|
ok(hres == S_OK, "parse_script failed: %08x\n", hres);
|
2008-09-05 02:38:44 +02:00
|
|
|
}
|
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
static void parse_script_a(const char *src)
|
|
|
|
{
|
|
|
|
parse_script_af(SCRIPTITEM_GLOBALMEMBERS, src);
|
|
|
|
}
|
|
|
|
|
2015-10-15 12:58:38 +02:00
|
|
|
static void parse_script_ae(const char *src, HRESULT exhres)
|
|
|
|
{
|
|
|
|
BSTR tmp;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
tmp = a2bstr(src);
|
|
|
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, tmp);
|
|
|
|
SysFreeString(tmp);
|
|
|
|
ok(hres == exhres, "parse_script failed: %08x, expected %08x\n", hres, exhres);
|
|
|
|
}
|
|
|
|
|
2010-10-09 16:43:48 +02:00
|
|
|
static void parse_script_with_error_a(const char *src, SCODE errorcode, ULONG line, LONG pos, LPCSTR source, LPCSTR desc, LPCSTR linetext)
|
|
|
|
{
|
|
|
|
BSTR tmp, script_source, description, line_text;
|
|
|
|
|
|
|
|
tmp = a2bstr(src);
|
|
|
|
script_source = a2bstr(source);
|
|
|
|
description = a2bstr(desc);
|
|
|
|
line_text = a2bstr(linetext);
|
|
|
|
|
|
|
|
parse_script_with_error(SCRIPTITEM_GLOBALMEMBERS, tmp, errorcode, line, pos, script_source, description, line_text);
|
|
|
|
|
|
|
|
SysFreeString(line_text);
|
|
|
|
SysFreeString(description);
|
|
|
|
SysFreeString(script_source);
|
|
|
|
SysFreeString(tmp);
|
|
|
|
}
|
|
|
|
|
2009-04-09 23:34:56 +02:00
|
|
|
static HRESULT parse_htmlscript_a(const char *src)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
BSTR tmp = a2bstr(src);
|
|
|
|
hres = parse_htmlscript(tmp);
|
|
|
|
SysFreeString(tmp);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2008-10-02 16:24:02 +02:00
|
|
|
static BSTR get_script_from_file(const char *filename)
|
|
|
|
{
|
|
|
|
DWORD size, len;
|
|
|
|
HANDLE file, map;
|
|
|
|
const char *file_map;
|
|
|
|
BSTR ret;
|
|
|
|
|
|
|
|
file = CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
|
|
|
|
if(file == INVALID_HANDLE_VALUE) {
|
|
|
|
trace("Could not open file: %u\n", GetLastError());
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = GetFileSize(file, NULL);
|
|
|
|
|
2013-10-14 16:05:34 +02:00
|
|
|
map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
|
2008-10-02 16:24:02 +02:00
|
|
|
CloseHandle(file);
|
|
|
|
if(map == INVALID_HANDLE_VALUE) {
|
|
|
|
trace("Could not create file mapping: %u\n", GetLastError());
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
file_map = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0);
|
|
|
|
CloseHandle(map);
|
|
|
|
if(!file_map) {
|
|
|
|
trace("MapViewOfFile failed: %u\n", GetLastError());
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, file_map, size, NULL, 0);
|
|
|
|
ret = SysAllocStringLen(NULL, len);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, file_map, size, ret, len);
|
|
|
|
|
|
|
|
UnmapViewOfFile(file_map);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void run_from_file(const char *filename)
|
|
|
|
{
|
2010-01-23 23:58:23 +01:00
|
|
|
BSTR script_str;
|
|
|
|
HRESULT hres;
|
2008-10-02 16:24:02 +02:00
|
|
|
|
2010-01-23 23:58:23 +01:00
|
|
|
script_str = get_script_from_file(filename);
|
|
|
|
if(!script_str)
|
|
|
|
return;
|
2008-10-02 16:24:02 +02:00
|
|
|
|
2010-01-23 23:58:23 +01:00
|
|
|
strict_dispid_check = FALSE;
|
|
|
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, script_str);
|
2008-10-02 16:24:02 +02:00
|
|
|
SysFreeString(script_str);
|
2010-01-23 23:58:23 +01:00
|
|
|
ok(hres == S_OK, "parse_script failed: %08x\n", hres);
|
2008-10-02 16:24:02 +02:00
|
|
|
}
|
|
|
|
|
2013-04-23 15:03:35 +02:00
|
|
|
static BSTR load_res(const char *name)
|
2008-09-09 01:25:23 +02:00
|
|
|
{
|
|
|
|
const char *data;
|
|
|
|
DWORD size, len;
|
|
|
|
BSTR str;
|
|
|
|
HRSRC src;
|
|
|
|
|
|
|
|
strict_dispid_check = FALSE;
|
|
|
|
test_name = name;
|
|
|
|
|
|
|
|
src = FindResourceA(NULL, name, (LPCSTR)40);
|
|
|
|
ok(src != NULL, "Could not find resource %s\n", name);
|
|
|
|
|
|
|
|
size = SizeofResource(NULL, src);
|
|
|
|
data = LoadResource(NULL, src);
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, data, size, NULL, 0);
|
2008-09-17 03:05:38 +02:00
|
|
|
str = SysAllocStringLen(NULL, len);
|
2011-02-17 03:43:24 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, data, size, str, len);
|
2008-09-09 01:25:23 +02:00
|
|
|
|
2013-04-23 15:03:35 +02:00
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void run_from_res(const char *name)
|
|
|
|
{
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
str = load_res(name);
|
|
|
|
|
2008-09-09 01:25:23 +02:00
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
2010-01-23 23:58:23 +01:00
|
|
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, str);
|
2008-09-09 01:25:23 +02:00
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
|
2010-01-23 23:58:23 +01:00
|
|
|
ok(hres == S_OK, "parse_script failed: %08x\n", hres);
|
2008-09-09 01:25:23 +02:00
|
|
|
SysFreeString(str);
|
|
|
|
}
|
|
|
|
|
2008-12-15 22:24:33 +01:00
|
|
|
static void test_isvisible(BOOL global_members)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *engine;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR script_textW[] =
|
|
|
|
{'v','a','r',' ','v',' ','=',' ','t','e','s','t','V','a','l',';',0};
|
|
|
|
|
|
|
|
engine = create_script();
|
|
|
|
if(!engine)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
2009-01-05 15:50:36 +01:00
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-15 22:24:33 +01:00
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
2008-12-15 22:24:33 +01:00
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
if(global_members)
|
|
|
|
SET_EXPECT(GetItemInfo_testVal);
|
|
|
|
hres = IActiveScript_AddNamedItem(engine, test_valW,
|
|
|
|
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|
|
|
|
|
(global_members ? SCRIPTITEM_GLOBALMEMBERS : 0));
|
|
|
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
|
|
|
if(global_members)
|
|
|
|
CHECK_CALLED(GetItemInfo_testVal);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
if(!global_members)
|
|
|
|
SET_EXPECT(GetItemInfo_testVal);
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, script_textW, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
2008-12-15 22:24:33 +01:00
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
if(!global_members)
|
|
|
|
CHECK_CALLED(GetItemInfo_testVal);
|
|
|
|
|
2012-07-30 12:02:01 +02:00
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, script_textW, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
2008-12-15 22:24:33 +01:00
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
|
|
|
|
IActiveScript_Release(engine);
|
2012-07-30 12:02:01 +02:00
|
|
|
IActiveScriptParse_Release(parser);
|
2008-12-15 22:24:33 +01:00
|
|
|
}
|
|
|
|
|
2015-01-13 21:46:02 +01:00
|
|
|
static void test_start(void)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *engine;
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
script_engine = engine = create_script();
|
|
|
|
if(!engine)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_AddNamedItem(engine, testW, SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
|
|
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
|
|
|
|
|
|
|
str = a2bstr("ok(getScriptState() === 5, \"getScriptState = \" + getScriptState());\n"
|
|
|
|
"reportSuccess();");
|
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
IActiveScriptParse_Release(parser);
|
|
|
|
script_engine = NULL;
|
|
|
|
}
|
|
|
|
|
2015-06-02 14:45:20 +02:00
|
|
|
static void test_automagic(void)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *engine;
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
script_engine = engine = create_script();
|
|
|
|
if(!engine)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_AddNamedItem(engine, testW, SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
|
|
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
|
|
|
|
|
|
|
str = a2bstr("function bindEventHandler::eventName() {}\n"
|
|
|
|
"reportSuccess();");
|
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
SET_EXPECT(BindHandler);
|
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(BindHandler);
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
IActiveScriptParse_Release(parser);
|
|
|
|
script_engine = NULL;
|
|
|
|
}
|
|
|
|
|
2015-01-13 21:45:56 +01:00
|
|
|
static HRESULT parse_script_expr(const char *expr, VARIANT *res, IActiveScript **engine_ret)
|
2012-12-12 13:12:39 +01:00
|
|
|
{
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *engine;
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
engine = create_script();
|
2018-01-08 15:57:22 +01:00
|
|
|
if(!engine)
|
|
|
|
return E_FAIL;
|
2012-12-12 13:12:39 +01:00
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(GetItemInfo_testVal);
|
|
|
|
hres = IActiveScript_AddNamedItem(engine, test_valW,
|
|
|
|
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
|
|
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(GetItemInfo_testVal);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
str = a2bstr(expr);
|
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, res, NULL);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
IActiveScriptParse_Release(parser);
|
|
|
|
|
2015-01-13 21:45:56 +01:00
|
|
|
if(engine_ret) {
|
|
|
|
*engine_ret = engine;
|
|
|
|
}else {
|
|
|
|
IActiveScript_Close(engine);
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
}
|
2012-12-12 13:12:39 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2015-05-29 18:07:37 +02:00
|
|
|
static void test_retval(void)
|
|
|
|
{
|
|
|
|
BSTR str = a2bstr("reportSuccess(), true");
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *engine;
|
|
|
|
SCRIPTSTATE state;
|
|
|
|
VARIANT res;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
engine = create_script();
|
2018-01-08 15:57:22 +01:00
|
|
|
if(!engine)
|
|
|
|
return;
|
2015-05-29 18:07:37 +02:00
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(GetItemInfo_testVal);
|
|
|
|
hres = IActiveScript_AddNamedItem(engine, test_valW,
|
|
|
|
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
|
|
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(GetItemInfo_testVal);
|
|
|
|
|
|
|
|
V_VT(&res) = VT_NULL;
|
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, &res, NULL);
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&res) == VT_EMPTY, "V_VT(&res) = %d\n", V_VT(&res));
|
|
|
|
|
|
|
|
hres = IActiveScript_GetScriptState(engine, &state);
|
|
|
|
ok(hres == S_OK, "GetScriptState failed: %08x\n", hres);
|
|
|
|
ok(state == SCRIPTSTATE_INITIALIZED, "state = %d\n", state);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_Close(engine);
|
|
|
|
ok(hres == S_OK, "Close failed: %08x\n", hres);
|
|
|
|
|
|
|
|
IActiveScriptParse_Release(parser);
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
SysFreeString(str);
|
|
|
|
}
|
|
|
|
|
2014-12-13 01:47:52 +01:00
|
|
|
static void test_default_value(void)
|
|
|
|
{
|
|
|
|
DISPPARAMS dp = {0};
|
|
|
|
IDispatch *disp;
|
|
|
|
VARIANT v;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2015-01-13 21:45:56 +01:00
|
|
|
hres = parse_script_expr("new Date()", &v, NULL);
|
2014-12-13 01:47:52 +01:00
|
|
|
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
2015-01-05 19:26:02 +01:00
|
|
|
ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
|
2014-12-13 01:47:52 +01:00
|
|
|
disp = V_DISPATCH(&v);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == 0x8000ffff), "Invoke failed: %08x\n", hres);
|
|
|
|
if(hres == S_OK)
|
|
|
|
{
|
|
|
|
ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
}
|
|
|
|
|
|
|
|
VariantClear(&v);
|
|
|
|
IDispatch_Release(disp);
|
|
|
|
}
|
|
|
|
|
2012-12-12 13:12:39 +01:00
|
|
|
static void test_script_exprs(void)
|
|
|
|
{
|
|
|
|
VARIANT v;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
testing_expr = TRUE;
|
|
|
|
|
2015-01-13 21:45:56 +01:00
|
|
|
hres = parse_script_expr("true", &v, NULL);
|
2012-12-12 13:12:39 +01:00
|
|
|
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
|
|
|
|
|
2015-01-13 21:45:56 +01:00
|
|
|
hres = parse_script_expr("false, true", &v, NULL);
|
2012-12-12 13:12:39 +01:00
|
|
|
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
|
|
|
|
|
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
2015-01-13 21:45:56 +01:00
|
|
|
hres = parse_script_expr("reportSuccess(); true", &v, NULL);
|
2012-12-12 13:12:39 +01:00
|
|
|
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
|
2015-01-13 21:45:56 +01:00
|
|
|
hres = parse_script_expr("if(false) true", &v, NULL);
|
2012-12-12 13:12:39 +01:00
|
|
|
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
|
2015-01-13 21:45:56 +01:00
|
|
|
hres = parse_script_expr("return testPropGet", &v, NULL);
|
2012-12-12 13:12:39 +01:00
|
|
|
ok(hres == 0x800a03fa, "parse_script_expr failed: %08x\n", hres);
|
|
|
|
|
2015-01-13 21:45:56 +01:00
|
|
|
hres = parse_script_expr("reportSuccess(); return true", &v, NULL);
|
2012-12-12 13:12:39 +01:00
|
|
|
ok(hres == 0x800a03fa, "parse_script_expr failed: %08x\n", hres);
|
|
|
|
|
2014-06-09 14:02:35 +02:00
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
2015-01-13 21:45:56 +01:00
|
|
|
hres = parse_script_expr("reportSuccess(); true", NULL, NULL);
|
2014-06-09 14:02:35 +02:00
|
|
|
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
|
2014-12-13 01:47:52 +01:00
|
|
|
test_default_value();
|
2015-05-29 18:07:37 +02:00
|
|
|
test_retval();
|
2014-12-13 01:47:52 +01:00
|
|
|
|
2012-12-12 13:12:39 +01:00
|
|
|
testing_expr = FALSE;
|
|
|
|
}
|
|
|
|
|
2015-01-13 21:45:56 +01:00
|
|
|
static void test_invokeex(void)
|
|
|
|
{
|
|
|
|
DISPID func_id, prop_id;
|
|
|
|
DISPPARAMS dp = {NULL};
|
|
|
|
IActiveScript *script;
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
VARIANT v;
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = parse_script_expr("var o = {func: function() {return 3;}, prop: 6}; o", &v, &script);
|
|
|
|
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
|
|
|
|
hres = IDispatch_QueryInterface(V_DISPATCH(&v), &IID_IDispatchEx, (void**)&dispex);
|
|
|
|
ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
|
|
|
|
VariantClear(&v);
|
|
|
|
|
|
|
|
str = a2bstr("func");
|
|
|
|
hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
|
|
|
|
SysFreeString(str);
|
|
|
|
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
|
|
|
|
|
|
|
str = a2bstr("prop");
|
|
|
|
hres = IDispatchEx_GetDispID(dispex, str, 0, &prop_id);
|
|
|
|
SysFreeString(str);
|
|
|
|
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, func_id, 0, DISPATCH_METHOD, &dp, &v, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
ok(V_I4(&v) == 3, "V_I4(v) = %d\n", V_I4(&v));
|
|
|
|
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
ok(V_I4(&v) == 6, "V_I4(v) = %d\n", V_I4(&v));
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
str = a2bstr("func");
|
|
|
|
hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
|
|
|
|
SysFreeString(str);
|
|
|
|
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, func_id, 0, DISPATCH_METHOD, &dp, &v, NULL, NULL);
|
|
|
|
ok(hres == E_UNEXPECTED || broken(hres == 0x800a1393), "InvokeEx failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IDispatchEx_InvokeEx(dispex, prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
|
|
|
|
ok(V_I4(&v) == 6, "V_I4(v) = %d\n", V_I4(&v));
|
|
|
|
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
IActiveScript_Release(script);
|
|
|
|
}
|
|
|
|
|
2019-05-20 21:05:25 +02:00
|
|
|
static void test_eval(void)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IDispatchEx *script_dispex;
|
|
|
|
IDispatch *script_disp;
|
|
|
|
IActiveScript *engine;
|
|
|
|
VARIANT arg, res;
|
|
|
|
DISPPARAMS params;
|
|
|
|
DISPID id, v_id;
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
engine = create_script();
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(GetItemInfo_testVal);
|
|
|
|
hres = IActiveScript_AddNamedItem(engine, test_valW,
|
|
|
|
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
|
|
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(GetItemInfo_testVal);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_GetScriptDispatch(engine, NULL, &script_disp);
|
|
|
|
ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
|
|
|
|
ok(script_disp != NULL, "script_disp == NULL\n");
|
|
|
|
|
|
|
|
hres = IDispatch_QueryInterface(script_disp, &IID_IDispatchEx, (void**)&script_dispex);
|
|
|
|
ok(hres == S_OK, "Coult not get IDispatchEx iface: %08x\n", hres);
|
|
|
|
IDispatch_Release(script_disp);
|
|
|
|
|
|
|
|
str = a2bstr("eval");
|
|
|
|
hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id);
|
|
|
|
ok(hres == S_OK, "Could not get eval dispid: %08x\n", hres);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
params.rgvarg = &arg;
|
|
|
|
params.rgdispidNamedArgs = NULL;
|
|
|
|
params.cArgs = 1;
|
|
|
|
params.cNamedArgs = 0;
|
|
|
|
V_VT(&arg) = VT_BSTR;
|
|
|
|
|
|
|
|
V_BSTR(&arg) = a2bstr("var v = 1;");
|
|
|
|
V_VT(&res) = VT_ERROR;
|
|
|
|
hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&res) == VT_EMPTY, "eval returned type %u\n", V_VT(&res));
|
|
|
|
SysFreeString(V_BSTR(&arg));
|
|
|
|
|
|
|
|
V_BSTR(&arg) = a2bstr("v");
|
|
|
|
V_VT(&res) = VT_ERROR;
|
|
|
|
hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res));
|
|
|
|
ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res));
|
|
|
|
SysFreeString(V_BSTR(&arg));
|
|
|
|
|
|
|
|
str = a2bstr("v");
|
|
|
|
hres = IDispatchEx_GetDispID(script_dispex, str, 0, &v_id);
|
|
|
|
ok(hres == S_OK, "Could not get v dispid: %08x\n", hres);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
params.rgvarg = NULL;
|
|
|
|
params.cArgs = 0;
|
|
|
|
V_VT(&res) = VT_ERROR;
|
|
|
|
hres = IDispatchEx_InvokeEx(script_dispex, v_id, 0, DISPATCH_PROPERTYGET, ¶ms, &res, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
|
|
|
ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res));
|
|
|
|
ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res));
|
|
|
|
|
|
|
|
SET_EXPECT(global_calleval_i);
|
|
|
|
str = a2bstr("(function(){"
|
|
|
|
" var v = 2;"
|
|
|
|
" callEval(eval);"
|
|
|
|
" ok(x === 5, 'x = ' + x);"
|
|
|
|
"})();");
|
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
SysFreeString(str);
|
|
|
|
CHECK_CALLED(global_calleval_i);
|
|
|
|
|
|
|
|
str = a2bstr("x");
|
|
|
|
hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id);
|
|
|
|
ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(x) returned %08x\n", hres);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
IDispatchEx_Release(script_dispex);
|
|
|
|
IActiveScriptParse_Release(parser);
|
|
|
|
IActiveScript_Close(engine);
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
}
|
|
|
|
|
2014-10-02 08:09:10 +02:00
|
|
|
struct bom_test
|
|
|
|
{
|
|
|
|
WCHAR str[1024];
|
|
|
|
HRESULT hres;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void run_bom_tests(void)
|
|
|
|
{
|
|
|
|
BSTR src;
|
|
|
|
int i;
|
|
|
|
HRESULT hres;
|
|
|
|
struct bom_test bom_tests[] = {
|
|
|
|
{{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
|
|
|
|
{{0xFEFF,'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
|
|
|
|
{{'v',0xFEFF,'a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, JS_E_OUT_OF_MEMORY},
|
|
|
|
{{'v','a','r',0xFEFF,' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
|
|
|
|
{{'v','a','r',' ','a',' ','=',' ','1',';',' ',0xFEFF,'r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
|
|
|
|
{{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t',0xFEFF,'S','u','c','c','e','s','s','(',')',';','\0'}, JS_E_OUT_OF_MEMORY},
|
|
|
|
{{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s',0xFEFF,'(',')',';','\0'}, S_OK},
|
|
|
|
{{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',0xFEFF,')',';','\0'}, S_OK},
|
|
|
|
{{'v','a','r',' ','a',' ','=',0xFEFF,' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',0xFEFF,')',';','\0'}, S_OK},
|
|
|
|
{{0xFEFF,'v','a','r',' ','a',' ','=',0xFEFF,0xFEFF,' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',0xFEFF,')',';','\0'}, S_OK},
|
|
|
|
{{0}}
|
|
|
|
};
|
|
|
|
|
|
|
|
engine_clsid = &CLSID_JScript;
|
|
|
|
|
|
|
|
for (i = 0; bom_tests[i].str[0]; i++)
|
|
|
|
{
|
|
|
|
if(bom_tests[i].hres == S_OK)
|
|
|
|
{
|
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
|
|
|
src = SysAllocString(bom_tests[i].str);
|
|
|
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
|
|
|
ok(hres == S_OK, "test %s failed with %08x\n", wine_dbgstr_w(src), hres);
|
|
|
|
SysFreeString(src);
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
src = SysAllocString(bom_tests[i].str);
|
|
|
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
|
|
|
todo_wine ok(hres == bom_tests[i].hres, "test %s returned with %08x\n", wine_dbgstr_w(src), hres);
|
|
|
|
SysFreeString(src);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-26 11:43:23 +02:00
|
|
|
static BOOL run_tests(void)
|
2008-09-05 02:38:44 +02:00
|
|
|
{
|
2009-04-09 23:34:56 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2009-10-19 20:41:32 +02:00
|
|
|
if(invoke_version) {
|
|
|
|
IActiveScript *script;
|
|
|
|
|
|
|
|
script = create_script();
|
|
|
|
if(!script) {
|
|
|
|
win_skip("Could not create script\n");
|
2012-03-26 11:43:23 +02:00
|
|
|
return FALSE;
|
2009-10-19 20:41:32 +02:00
|
|
|
}
|
|
|
|
IActiveScript_Release(script);
|
|
|
|
}
|
|
|
|
|
2008-09-09 01:25:23 +02:00
|
|
|
strict_dispid_check = TRUE;
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
parse_script_a("");
|
2008-09-05 02:39:07 +02:00
|
|
|
parse_script_a("/* empty */ ;");
|
2008-09-09 01:22:31 +02:00
|
|
|
|
|
|
|
SET_EXPECT(global_propget_d);
|
|
|
|
SET_EXPECT(global_propget_i);
|
|
|
|
parse_script_a("testPropGet;");
|
|
|
|
CHECK_CALLED(global_propget_d);
|
|
|
|
CHECK_CALLED(global_propget_i);
|
2008-09-09 01:24:02 +02:00
|
|
|
|
|
|
|
SET_EXPECT(global_propput_d);
|
|
|
|
SET_EXPECT(global_propput_i);
|
|
|
|
parse_script_a("testPropPut = 1;");
|
|
|
|
CHECK_CALLED(global_propput_d);
|
|
|
|
CHECK_CALLED(global_propput_i);
|
2008-09-09 01:25:05 +02:00
|
|
|
|
2014-11-28 16:18:32 +01:00
|
|
|
SET_EXPECT(global_propputref_d);
|
|
|
|
SET_EXPECT(global_propputref_i);
|
|
|
|
parse_script_a("testPropPutRef = new Object();");
|
|
|
|
CHECK_CALLED(global_propputref_d);
|
|
|
|
CHECK_CALLED(global_propputref_i);
|
|
|
|
|
|
|
|
SET_EXPECT(global_propputref_d);
|
|
|
|
SET_EXPECT(global_propputref_i);
|
|
|
|
parse_script_a("testPropPutRef = testObj;");
|
|
|
|
CHECK_CALLED(global_propputref_d);
|
|
|
|
CHECK_CALLED(global_propputref_i);
|
|
|
|
|
2008-09-09 01:25:05 +02:00
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
|
|
|
parse_script_a("reportSuccess();");
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
2008-09-09 01:25:23 +02:00
|
|
|
|
2012-12-17 13:36:44 +01:00
|
|
|
SET_EXPECT(testobj_delete_test);
|
|
|
|
parse_script_a("ok((delete testObj.deleteTest) === true, 'delete testObj.deleteTest did not return true');");
|
|
|
|
CHECK_CALLED(testobj_delete_test);
|
|
|
|
|
|
|
|
SET_EXPECT(testobj_delete_nodelete);
|
|
|
|
parse_script_a("ok((delete testObj.noDeleteTest) === false, 'delete testObj.noDeleteTest did not return false');");
|
|
|
|
CHECK_CALLED(testobj_delete_nodelete);
|
2008-09-19 00:43:37 +02:00
|
|
|
|
2011-12-15 15:42:41 +01:00
|
|
|
SET_EXPECT(global_propdelete_d);
|
|
|
|
SET_EXPECT(DeleteMemberByDispID);
|
2012-12-17 13:36:55 +01:00
|
|
|
parse_script_a("ok((delete testPropDelete) === true, 'delete testPropDelete did not return true');");
|
2011-12-15 15:42:41 +01:00
|
|
|
CHECK_CALLED(global_propdelete_d);
|
|
|
|
CHECK_CALLED(DeleteMemberByDispID);
|
|
|
|
|
2012-12-17 13:36:55 +01:00
|
|
|
SET_EXPECT(global_nopropdelete_d);
|
|
|
|
SET_EXPECT(DeleteMemberByDispID_false);
|
|
|
|
parse_script_a("ok((delete testNoPropDelete) === false, 'delete testPropDelete did not return false');");
|
|
|
|
CHECK_CALLED(global_nopropdelete_d);
|
|
|
|
CHECK_CALLED(DeleteMemberByDispID_false);
|
|
|
|
|
2015-10-15 12:58:38 +02:00
|
|
|
SET_EXPECT(global_propdeleteerror_d);
|
|
|
|
SET_EXPECT(DeleteMemberByDispID_error);
|
|
|
|
parse_script_ae("delete testPropDeleteError;", E_FAIL);
|
|
|
|
CHECK_CALLED(global_propdeleteerror_d);
|
|
|
|
CHECK_CALLED(DeleteMemberByDispID_error);
|
|
|
|
|
2012-12-17 13:36:31 +01:00
|
|
|
SET_EXPECT(puredisp_prop_d);
|
|
|
|
parse_script_a("ok((delete pureDisp.prop) === false, 'delete pureDisp.prop did not return true');");
|
|
|
|
CHECK_CALLED(puredisp_prop_d);
|
|
|
|
|
|
|
|
SET_EXPECT(puredisp_noprop_d);
|
|
|
|
parse_script_a("ok((delete pureDisp.noprop) === true, 'delete pureDisp.noprop did not return false');");
|
|
|
|
CHECK_CALLED(puredisp_noprop_d);
|
|
|
|
|
2012-12-24 11:38:28 +01:00
|
|
|
SET_EXPECT(puredisp_value);
|
|
|
|
parse_script_a("var t=pureDisp; t=t(false);");
|
|
|
|
CHECK_CALLED(puredisp_value);
|
|
|
|
|
|
|
|
SET_EXPECT(puredisp_value);
|
|
|
|
parse_script_a("var t = {func: pureDisp}; t = t.func(false);");
|
|
|
|
CHECK_CALLED(puredisp_value);
|
|
|
|
|
|
|
|
SET_EXPECT(dispexfunc_value);
|
|
|
|
parse_script_a("var t = dispexFunc; t = t(false);");
|
|
|
|
CHECK_CALLED(dispexfunc_value);
|
|
|
|
|
|
|
|
SET_EXPECT(dispexfunc_value);
|
|
|
|
parse_script_a("var t = {func: dispexFunc}; t = t.func(false);");
|
|
|
|
CHECK_CALLED(dispexfunc_value);
|
|
|
|
|
2016-06-15 18:37:13 +02:00
|
|
|
SET_EXPECT(dispexfunc_value);
|
|
|
|
parse_script_a("Function.prototype.apply.call(dispexFunc, testObj, [true]);");
|
|
|
|
CHECK_CALLED(dispexfunc_value);
|
|
|
|
|
|
|
|
SET_EXPECT(puredisp_value);
|
|
|
|
parse_script_a("Function.prototype.apply.call(pureDisp, testObj, [true]);");
|
|
|
|
CHECK_CALLED(puredisp_value);
|
|
|
|
|
2011-12-16 11:42:57 +01:00
|
|
|
parse_script_a("(function reportSuccess() {})()");
|
|
|
|
|
2008-11-05 01:03:38 +01:00
|
|
|
parse_script_a("ok(typeof(test) === 'object', \"typeof(test) != 'object'\");");
|
|
|
|
|
2009-08-10 12:57:23 +02:00
|
|
|
parse_script_a("function reportSuccess() {}; reportSuccess();");
|
|
|
|
|
2009-08-10 12:57:42 +02:00
|
|
|
SET_EXPECT(global_propget_d);
|
|
|
|
parse_script_a("var testPropGet");
|
|
|
|
CHECK_CALLED(global_propget_d);
|
|
|
|
|
2010-10-14 15:21:13 +02:00
|
|
|
SET_EXPECT(global_propget_d);
|
|
|
|
parse_script_a("eval('var testPropGet;');");
|
|
|
|
CHECK_CALLED(global_propget_d);
|
|
|
|
|
2016-08-04 13:39:46 +02:00
|
|
|
parse_script_a("var testPropGet; function testPropGet() {}");
|
|
|
|
|
2009-08-10 12:57:42 +02:00
|
|
|
SET_EXPECT(global_notexists_d);
|
|
|
|
parse_script_a("var notExists; notExists = 1;");
|
|
|
|
CHECK_CALLED(global_notexists_d);
|
|
|
|
|
2014-06-12 10:44:03 +02:00
|
|
|
SET_EXPECT(testobj_notexists_d);
|
|
|
|
parse_script_a("testObj.notExists;");
|
|
|
|
CHECK_CALLED(testobj_notexists_d);
|
|
|
|
|
2009-08-10 12:57:42 +02:00
|
|
|
parse_script_a("function f() { var testPropGet; }");
|
2010-10-14 15:21:13 +02:00
|
|
|
parse_script_a("(function () { var testPropGet; })();");
|
|
|
|
parse_script_a("(function () { eval('var testPropGet;'); })();");
|
2009-08-10 12:57:42 +02:00
|
|
|
|
2010-10-19 23:14:35 +02:00
|
|
|
SET_EXPECT(invoke_func);
|
|
|
|
parse_script_a("ok(propGetFunc() == 0, \"Incorrect propGetFunc value\");");
|
|
|
|
CHECK_CALLED(invoke_func);
|
|
|
|
parse_script_a("ok(propGetFunc(1) == 1, \"Incorrect propGetFunc value\");");
|
|
|
|
parse_script_a("ok(propGetFunc(1, 2) == 2, \"Incorrect propGetFunc value\");");
|
|
|
|
SET_EXPECT(invoke_func);
|
|
|
|
parse_script_a("ok(propGetFunc().toString() == 0, \"Incorrect propGetFunc value\");");
|
|
|
|
CHECK_CALLED(invoke_func);
|
|
|
|
parse_script_a("ok(propGetFunc(1).toString() == 1, \"Incorrect propGetFunc value\");");
|
|
|
|
SET_EXPECT(invoke_func);
|
|
|
|
parse_script_a("propGetFunc(1);");
|
|
|
|
CHECK_CALLED(invoke_func);
|
|
|
|
|
|
|
|
parse_script_a("objectFlag(1).toString();");
|
|
|
|
|
|
|
|
parse_script_a("(function() { var tmp = (function () { return testObj; })()(1);})();");
|
|
|
|
parse_script_a("(function() { var tmp = (function () { return testObj; })()();})();");
|
|
|
|
|
2009-08-29 00:01:25 +02:00
|
|
|
parse_script_a("ok((testObj instanceof Object) === false, 'testObj is instance of Object');");
|
|
|
|
|
2009-09-06 19:10:06 +02:00
|
|
|
SET_EXPECT(testobj_prop_d);
|
|
|
|
parse_script_a("ok(('prop' in testObj) === true, 'prop is not in testObj');");
|
|
|
|
CHECK_CALLED(testobj_prop_d);
|
|
|
|
|
|
|
|
SET_EXPECT(testobj_noprop_d);
|
|
|
|
parse_script_a("ok(('noprop' in testObj) === false, 'noprop is in testObj');");
|
|
|
|
CHECK_CALLED(testobj_noprop_d);
|
|
|
|
|
2011-09-02 12:24:12 +02:00
|
|
|
SET_EXPECT(testobj_prop_d);
|
|
|
|
parse_script_a("ok(Object.prototype.hasOwnProperty.call(testObj, 'prop') === true, 'hasOwnProperty(\\\"prop\\\") returned false');");
|
|
|
|
CHECK_CALLED(testobj_prop_d);
|
|
|
|
|
|
|
|
SET_EXPECT(testobj_noprop_d);
|
|
|
|
parse_script_a("ok(Object.prototype.hasOwnProperty.call(testObj, 'noprop') === false, 'hasOwnProperty(\\\"noprop\\\") returned true');");
|
|
|
|
CHECK_CALLED(testobj_noprop_d);
|
|
|
|
|
|
|
|
SET_EXPECT(puredisp_prop_d);
|
|
|
|
parse_script_a("ok(Object.prototype.hasOwnProperty.call(pureDisp, 'prop') === true, 'hasOwnProperty(\\\"noprop\\\") returned false');");
|
|
|
|
CHECK_CALLED(puredisp_prop_d);
|
|
|
|
|
|
|
|
SET_EXPECT(puredisp_noprop_d);
|
|
|
|
parse_script_a("ok(Object.prototype.hasOwnProperty.call(pureDisp, 'noprop') === false, 'hasOwnProperty(\\\"noprop\\\") returned true');");
|
|
|
|
CHECK_CALLED(puredisp_noprop_d);
|
|
|
|
|
2009-09-02 12:25:21 +02:00
|
|
|
SET_EXPECT(testobj_value);
|
|
|
|
parse_script_a("ok(String(testObj) === '1', 'wrong testObj value');");
|
|
|
|
CHECK_CALLED(testobj_value);
|
|
|
|
|
2009-09-23 16:19:29 +02:00
|
|
|
SET_EXPECT(testobj_value);
|
|
|
|
parse_script_a("ok(String.prototype.concat.call(testObj, ' OK') === '1 OK', 'wrong concat result');");
|
|
|
|
CHECK_CALLED(testobj_value);
|
|
|
|
|
2014-09-16 20:42:33 +02:00
|
|
|
SET_EXPECT(testobj_construct);
|
|
|
|
parse_script_a("var t = new testObj(1);");
|
|
|
|
CHECK_CALLED(testobj_construct);
|
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
SET_EXPECT(global_propget_d);
|
|
|
|
SET_EXPECT(global_propget_i);
|
|
|
|
parse_script_a("this.testPropGet;");
|
|
|
|
CHECK_CALLED(global_propget_d);
|
|
|
|
CHECK_CALLED(global_propget_i);
|
|
|
|
|
2014-11-28 16:18:32 +01:00
|
|
|
SET_EXPECT(global_propputref_d);
|
|
|
|
SET_EXPECT(global_propputref_i);
|
|
|
|
parse_script_a("testPropPutRef = nullDisp;");
|
|
|
|
CHECK_CALLED(global_propputref_d);
|
|
|
|
CHECK_CALLED(global_propputref_i);
|
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
SET_EXPECT(global_propget_d);
|
|
|
|
SET_EXPECT(global_propget_i);
|
|
|
|
parse_script_a("(function () { this.testPropGet; })();");
|
|
|
|
CHECK_CALLED(global_propget_d);
|
|
|
|
CHECK_CALLED(global_propget_i);
|
|
|
|
|
|
|
|
parse_script_a("testThis(this);");
|
|
|
|
parse_script_a("(function () { testThis(this); })();");
|
2012-11-14 15:49:46 +01:00
|
|
|
parse_script_a("function x() { testThis(this); }; x();");
|
|
|
|
parse_script_a("var t = {func: function () { ok(this === t, 'this !== t'); }}; with(t) { func(); }");
|
|
|
|
parse_script_a("function x() { testThis(this); }; with({y: 1}) { x(); }");
|
|
|
|
parse_script_a("(function () { function x() { testThis(this);} x(); })();");
|
2009-09-27 20:59:28 +02:00
|
|
|
|
2010-12-29 16:02:25 +01:00
|
|
|
SET_EXPECT(testobj_onlydispid_d);
|
|
|
|
SET_EXPECT(testobj_onlydispid_i);
|
|
|
|
parse_script_a("ok(typeof(testObj.onlyDispID) === 'unknown', 'unexpected typeof(testObj.onlyDispID)');");
|
|
|
|
CHECK_CALLED(testobj_onlydispid_d);
|
|
|
|
CHECK_CALLED(testobj_onlydispid_i);
|
|
|
|
|
2012-04-17 16:26:16 +02:00
|
|
|
SET_EXPECT(global_propargput_d);
|
|
|
|
SET_EXPECT(global_propargput_i);
|
|
|
|
parse_script_a("var t=0; propArgPutG(t++, t++) = t++;");
|
|
|
|
CHECK_CALLED(global_propargput_d);
|
|
|
|
CHECK_CALLED(global_propargput_i);
|
|
|
|
|
|
|
|
SET_EXPECT(global_propargput_d);
|
|
|
|
SET_EXPECT(global_propargput_i);
|
|
|
|
parse_script_a("var t=0; test.propArgPutO(t++, t++) = t++;");
|
|
|
|
CHECK_CALLED(global_propargput_d);
|
|
|
|
CHECK_CALLED(global_propargput_i);
|
|
|
|
|
2012-05-01 15:05:21 +02:00
|
|
|
SET_EXPECT(global_testargtypes_i);
|
2017-08-21 21:34:39 +02:00
|
|
|
parse_script_a("testArgTypes(dispUnk, intProp(), intProp, getShort(), shortProp,"
|
2017-11-01 16:43:37 +01:00
|
|
|
"function(ui2,r4,i4ref,ui4,nullunk,d,i,s) {"
|
2012-05-04 15:59:43 +02:00
|
|
|
" ok(getVT(i) === 'VT_I4', 'getVT(i) = ' + getVT(i));"
|
|
|
|
" ok(getVT(s) === 'VT_I4', 'getVT(s) = ' + getVT(s));"
|
2012-12-05 14:49:42 +01:00
|
|
|
" ok(getVT(d) === 'VT_DISPATCH', 'getVT(d) = ' + getVT(d));"
|
2014-03-19 13:15:14 +01:00
|
|
|
" ok(getVT(nullunk) === 'VT_DISPATCH', 'getVT(nullunk) = ' + getVT(nullunk));"
|
|
|
|
" ok(nullunk === null, 'nullunk !== null');"
|
2015-02-06 12:10:00 +01:00
|
|
|
" ok(getVT(ui4) === 'VT_R8', 'getVT(ui4) = ' + getVT(ui4));"
|
2015-02-03 19:37:07 +01:00
|
|
|
" ok(ui4 > 0, 'ui4 = ' + ui4);"
|
2015-02-06 12:10:00 +01:00
|
|
|
" ok(getVT(i4ref) === 'VT_I4', 'getVT(i4ref) = ' + getVT(i4ref));"
|
|
|
|
" ok(i4ref === 2, 'i4ref = ' + i4ref);"
|
2017-08-21 21:34:39 +02:00
|
|
|
" ok(r4 === 0.5, 'r4 = ' + r4);"
|
|
|
|
" ok(getVT(r4) === 'VT_R8', 'getVT(r4) = ' + getVT(r4));"
|
2017-11-01 16:43:37 +01:00
|
|
|
" ok(getVT(ui2) === 'VT_I4', 'getVT(ui2) = ' + getVT(ui2));"
|
2012-05-04 15:59:43 +02:00
|
|
|
"});");
|
2012-05-01 15:05:21 +02:00
|
|
|
CHECK_CALLED(global_testargtypes_i);
|
|
|
|
|
2012-09-13 14:34:25 +02:00
|
|
|
SET_EXPECT(testobj_withprop_d);
|
|
|
|
SET_EXPECT(testobj_withprop_i);
|
|
|
|
parse_script_a("var t = (function () { with(testObj) { return withProp; }})(); ok(t === 1, 't = ' + t);");
|
|
|
|
CHECK_CALLED(testobj_withprop_d);
|
|
|
|
CHECK_CALLED(testobj_withprop_i);
|
|
|
|
|
2014-10-01 10:45:30 +02:00
|
|
|
parse_script_a("@set @t=2\nok(@t === 2, '@t = ' + @t);");
|
|
|
|
|
2014-10-01 10:45:37 +02:00
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
|
|
|
parse_script_a("@if(true)\nif(@_jscript) reportSuccess();\n@end");
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
|
2019-05-17 16:39:32 +02:00
|
|
|
EnumVARIANT_index = 0;
|
|
|
|
EnumVARIANT_next_0_count = 1;
|
|
|
|
SET_EXPECT(testobj_newenum);
|
|
|
|
SET_EXPECT(enumvariant_next_0);
|
|
|
|
parse_script_a("new Enumerator(testObj);");
|
|
|
|
CHECK_CALLED(testobj_newenum);
|
|
|
|
CHECK_CALLED(enumvariant_next_0);
|
|
|
|
|
|
|
|
EnumVARIANT_index = 0;
|
|
|
|
EnumVARIANT_next_0_count = 2;
|
|
|
|
SET_EXPECT(testobj_newenum);
|
|
|
|
SET_EXPECT(enumvariant_next_0);
|
|
|
|
SET_EXPECT(enumvariant_reset);
|
|
|
|
parse_script_a("(function () {"
|
|
|
|
" var testEnumObj = new Enumerator(testObj);"
|
|
|
|
" var tmp = testEnumObj.moveFirst();"
|
|
|
|
" ok(tmp == undefined, \"testEnumObj.moveFirst() = \" + tmp);"
|
|
|
|
"})()");
|
|
|
|
CHECK_CALLED(testobj_newenum);
|
|
|
|
CHECK_CALLED(enumvariant_next_0);
|
|
|
|
CHECK_CALLED(enumvariant_reset);
|
|
|
|
|
|
|
|
EnumVARIANT_index = 0;
|
|
|
|
EnumVARIANT_next_0_count = 1;
|
|
|
|
SET_EXPECT(testobj_newenum);
|
|
|
|
SET_EXPECT(enumvariant_next_0);
|
|
|
|
SET_EXPECT(enumvariant_next_1);
|
|
|
|
parse_script_a("(function () {"
|
|
|
|
" var testEnumObj = new Enumerator(testObj);"
|
|
|
|
" while (!testEnumObj.atEnd())"
|
|
|
|
" {"
|
|
|
|
" ok(testEnumObj.item() == 123, "
|
|
|
|
" \"testEnumObj.item() = \"+testEnumObj.item());"
|
|
|
|
" testEnumObj.moveNext();"
|
|
|
|
" }"
|
|
|
|
"})()");
|
|
|
|
CHECK_CALLED(testobj_newenum);
|
|
|
|
CHECK_CALLED(enumvariant_next_0);
|
|
|
|
CHECK_CALLED(enumvariant_next_1);
|
|
|
|
|
2008-09-09 01:25:23 +02:00
|
|
|
run_from_res("lang.js");
|
2008-09-15 20:37:10 +02:00
|
|
|
run_from_res("api.js");
|
2008-09-15 20:41:23 +02:00
|
|
|
run_from_res("regexp.js");
|
2010-12-28 15:40:39 +01:00
|
|
|
run_from_res("cc.js");
|
2008-12-15 22:24:33 +01:00
|
|
|
|
|
|
|
test_isvisible(FALSE);
|
|
|
|
test_isvisible(TRUE);
|
2015-01-13 21:46:02 +01:00
|
|
|
test_start();
|
2015-06-02 14:45:20 +02:00
|
|
|
test_automagic();
|
2009-04-09 23:34:56 +02:00
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
parse_script_af(0, "test.testThis2(this);");
|
|
|
|
parse_script_af(0, "(function () { test.testThis2(this); })();");
|
|
|
|
|
2009-04-09 23:34:56 +02:00
|
|
|
hres = parse_htmlscript_a("<!--");
|
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
hres = parse_htmlscript_a("-->");
|
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
hres = parse_htmlscript_a("<!--\nvar a=1;\n-->\n");
|
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
hres = parse_htmlscript_a("<!--\n<!-- ignore this\n-->\n");
|
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
hres = parse_htmlscript_a("var a=1;\nif(a-->0) a=5;\n");
|
|
|
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
|
|
|
hres = parse_htmlscript_a("var a=1;\nif(a\n-->0) a=5;\n");
|
|
|
|
ok(hres != S_OK, "ParseScriptText have not failed\n");
|
2010-10-09 16:43:48 +02:00
|
|
|
|
2012-12-12 13:12:39 +01:00
|
|
|
test_script_exprs();
|
2015-01-13 21:45:56 +01:00
|
|
|
test_invokeex();
|
2019-05-20 21:05:25 +02:00
|
|
|
test_eval();
|
2012-12-12 13:12:39 +01:00
|
|
|
|
2010-10-09 16:43:48 +02:00
|
|
|
parse_script_with_error_a(
|
|
|
|
"?",
|
|
|
|
0x800a03ea, 0, 0,
|
|
|
|
"Microsoft JScript compilation error",
|
|
|
|
"Syntax error",
|
|
|
|
"?");
|
|
|
|
|
|
|
|
parse_script_with_error_a(
|
|
|
|
"var a=1;\nif(a\n-->0) a=5;\n",
|
|
|
|
0x800a03ee, 2, 0,
|
|
|
|
"Microsoft JScript compilation error",
|
|
|
|
"Expected ')'",
|
|
|
|
"-->0) a=5;");
|
|
|
|
|
|
|
|
parse_script_with_error_a(
|
|
|
|
"new 3;",
|
|
|
|
0x800a01bd, 0, 0,
|
|
|
|
"Microsoft JScript runtime error",
|
|
|
|
"Object doesn't support this action",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
parse_script_with_error_a(
|
|
|
|
"new null;",
|
|
|
|
0x800a138f, 0, 0,
|
|
|
|
"Microsoft JScript runtime error",
|
|
|
|
"Object expected",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
parse_script_with_error_a(
|
|
|
|
"var a;\nnew null;",
|
|
|
|
0x800a138f, 1, 0,
|
|
|
|
"Microsoft JScript runtime error",
|
|
|
|
"Object expected",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
parse_script_with_error_a(
|
|
|
|
"var a; new null;",
|
|
|
|
0x800a138f, 0, 7,
|
|
|
|
"Microsoft JScript runtime error",
|
|
|
|
"Object expected",
|
|
|
|
NULL);
|
2012-03-26 11:43:23 +02:00
|
|
|
|
2014-10-02 08:09:10 +02:00
|
|
|
run_bom_tests();
|
|
|
|
|
2012-03-26 11:43:23 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-10-04 14:57:46 +02:00
|
|
|
static void test_parse_proc(void)
|
|
|
|
{
|
|
|
|
VARIANT args[2];
|
|
|
|
DISPPARAMS dp = {args};
|
|
|
|
|
|
|
|
dp.cArgs = 0;
|
|
|
|
invoke_procedure(NULL, "return true;", &dp);
|
|
|
|
|
|
|
|
dp.cArgs = 1;
|
|
|
|
V_VT(args) = VT_EMPTY;
|
|
|
|
invoke_procedure(NULL, "return arguments.length == 1;", &dp);
|
2012-10-04 14:58:05 +02:00
|
|
|
|
|
|
|
V_VT(args) = VT_BOOL;
|
|
|
|
V_BOOL(args) = VARIANT_TRUE;
|
|
|
|
invoke_procedure(" x ", "return x;", &dp);
|
|
|
|
|
|
|
|
dp.cArgs = 2;
|
|
|
|
V_VT(args) = VT_I4;
|
|
|
|
V_I4(args) = 2;
|
|
|
|
V_VT(args+1) = VT_I4;
|
|
|
|
V_I4(args+1) = 1;
|
|
|
|
invoke_procedure(" _x1 , y_2", "return _x1 === 1 && y_2 === 2;", &dp);
|
2012-10-04 14:57:46 +02:00
|
|
|
}
|
|
|
|
|
2012-03-26 11:43:23 +02:00
|
|
|
static void run_encoded_tests(void)
|
|
|
|
{
|
|
|
|
BSTR src;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
engine_clsid = &CLSID_JScriptEncode;
|
|
|
|
|
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
|
|
|
/* |reportSuccess(); | */
|
|
|
|
parse_script_a("#@~^EAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
|
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
|
|
|
parse_script_a("reportSuccess();");
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
|
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
|
|
|
/* |Success | */
|
|
|
|
parse_script_a("report#@~^BwAAAA==j!m^\x7f/k2QIAAA==^#~@();");
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
|
|
|
|
SET_EXPECT(global_success_d);
|
|
|
|
SET_EXPECT(global_success_i);
|
|
|
|
/* |\r\n\treportSuccess();\r\n | */
|
|
|
|
parse_script_a("#@~^GQAAAA==@#@&d.\x7fwKDYUE1^+k/c#p@#@&OAYAAA==^#~@");
|
|
|
|
CHECK_CALLED(global_success_d);
|
|
|
|
CHECK_CALLED(global_success_i);
|
|
|
|
|
|
|
|
/* v */
|
|
|
|
src = a2bstr("#@~^EAA*AA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
|
|
|
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
|
|
|
SysFreeString(src);
|
|
|
|
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
|
|
|
|
|
|
|
/* vv */
|
|
|
|
src = a2bstr("#@~^EAAAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
|
|
|
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
|
|
|
SysFreeString(src);
|
|
|
|
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
|
|
|
|
|
|
|
/* v */
|
|
|
|
src = a2bstr("#@~^EAAAAA^=.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
|
|
|
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
|
|
|
SysFreeString(src);
|
|
|
|
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
|
|
|
|
|
|
|
/* v */
|
|
|
|
src = a2bstr("#@~^EAAAAA==.\x7fwGMYUEm1ekd`*iAQYAAA==^#~@");
|
|
|
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
|
|
|
SysFreeString(src);
|
|
|
|
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
|
|
|
|
|
|
|
/* vv */
|
|
|
|
src = a2bstr("#@~^EAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^~#@");
|
|
|
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
|
|
|
SysFreeString(src);
|
|
|
|
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
2008-09-05 02:38:44 +02:00
|
|
|
}
|
|
|
|
|
2013-04-23 15:03:35 +02:00
|
|
|
static void run_benchmark(const char *script_name)
|
|
|
|
{
|
|
|
|
IActiveScriptParse *parser;
|
|
|
|
IActiveScript *engine;
|
|
|
|
ULONG start, end;
|
|
|
|
BSTR src;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
engine = create_script();
|
|
|
|
if(!engine)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
|
|
|
|
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
|
|
|
if (FAILED(hres)) {
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IActiveScriptParse_InitNew(parser);
|
|
|
|
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
|
|
|
|
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_AddNamedItem(engine, testW,
|
|
|
|
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE);
|
|
|
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
|
|
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
src = load_res(script_name);
|
|
|
|
|
|
|
|
start = GetTickCount();
|
|
|
|
hres = IActiveScriptParse_ParseScriptText(parser, src, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
|
|
|
end = GetTickCount();
|
|
|
|
ok(hres == S_OK, "%s: ParseScriptText failed: %08x\n", script_name, hres);
|
|
|
|
|
|
|
|
trace("%s ran in %u ms\n", script_name, end-start);
|
|
|
|
|
|
|
|
IActiveScript_Release(engine);
|
|
|
|
IActiveScriptParse_Release(parser);
|
|
|
|
SysFreeString(src);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void run_benchmarks(void)
|
|
|
|
{
|
|
|
|
trace("Running benchmarks...\n");
|
|
|
|
|
|
|
|
run_benchmark("dna.js");
|
|
|
|
run_benchmark("base64.js");
|
|
|
|
run_benchmark("validateinput.js");
|
|
|
|
}
|
|
|
|
|
2010-01-23 23:58:23 +01:00
|
|
|
static BOOL check_jscript(void)
|
|
|
|
{
|
2010-09-21 15:58:48 +02:00
|
|
|
IActiveScriptProperty *script_prop;
|
2010-01-23 23:58:23 +01:00
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2010-09-21 15:58:48 +02:00
|
|
|
hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
|
|
|
&IID_IActiveScriptProperty, (void**)&script_prop);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return FALSE;
|
|
|
|
IActiveScriptProperty_Release(script_prop);
|
|
|
|
|
2010-01-23 23:58:23 +01:00
|
|
|
str = a2bstr("if(!('localeCompare' in String.prototype)) throw 1;");
|
|
|
|
hres = parse_script(0, str);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
return hres == S_OK;
|
|
|
|
}
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
START_TEST(run)
|
|
|
|
{
|
2008-10-02 16:24:02 +02:00
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
|
|
|
|
argc = winetest_get_mainargs(&argv);
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2010-01-23 23:58:23 +01:00
|
|
|
if(!check_jscript()) {
|
|
|
|
win_skip("Broken engine, probably too old\n");
|
|
|
|
}else if(argc > 2) {
|
2012-01-12 13:43:38 +01:00
|
|
|
invoke_version = 2;
|
2008-10-02 16:24:02 +02:00
|
|
|
run_from_file(argv[2]);
|
2009-10-19 20:41:32 +02:00
|
|
|
}else {
|
|
|
|
trace("invoke version 0\n");
|
|
|
|
invoke_version = 0;
|
2008-10-02 16:24:02 +02:00
|
|
|
run_tests();
|
2008-09-05 02:38:44 +02:00
|
|
|
|
2009-10-19 20:41:32 +02:00
|
|
|
trace("invoke version 2\n");
|
|
|
|
invoke_version = 2;
|
2012-03-26 11:43:23 +02:00
|
|
|
if(run_tests()) {
|
|
|
|
trace("JSctipt.Encode tests...\n");
|
|
|
|
run_encoded_tests();
|
2012-10-04 14:57:46 +02:00
|
|
|
trace("ParseProcedureText tests...\n");
|
|
|
|
test_parse_proc();
|
2012-03-26 11:43:23 +02:00
|
|
|
}
|
2013-04-23 15:03:35 +02:00
|
|
|
|
|
|
|
if(winetest_interactive)
|
|
|
|
run_benchmarks();
|
2009-10-19 20:41:32 +02:00
|
|
|
}
|
|
|
|
|
2008-09-05 02:38:44 +02:00
|
|
|
CoUninitialize();
|
|
|
|
}
|