Author: cwittich
Date: Tue Mar 2 20:52:22 2010
New Revision: 45767
URL:
http://svn.reactos.org/svn/reactos?rev=45767&view=rev
Log:
[JSCRIPT_WINETEST]
sync jscript_winetest to wine 1.1.39
Added:
trunk/rostests/winetests/jscript/activex.c (with props)
Modified:
trunk/rostests/winetests/jscript/api.js
trunk/rostests/winetests/jscript/jscript.c
trunk/rostests/winetests/jscript/jscript.rbuild
trunk/rostests/winetests/jscript/lang.js
trunk/rostests/winetests/jscript/regexp.js
trunk/rostests/winetests/jscript/run.c
trunk/rostests/winetests/jscript/testlist.c
Added: trunk/rostests/winetests/jscript/activex.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/jscript/activex…
==============================================================================
--- trunk/rostests/winetests/jscript/activex.c (added)
+++ trunk/rostests/winetests/jscript/activex.c [iso-8859-1] Tue Mar 2 20:52:22 2010
@@ -1,0 +1,1096 @@
+/*
+ * Copyright 2009 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 <objsafe.h>
+#include <urlmon.h>
+#include <mshtmhst.h>
+
+#include "wine/test.h"
+
+static const CLSID CLSID_JScript =
+ {0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
+
+#define DEFINE_EXPECT(func) \
+ static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
+
+#define SET_EXPECT(func) \
+ expect_ ## func = TRUE
+
+#define SET_CALLED(func) \
+ called_ ## 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)
+
+DEFINE_EXPECT(CreateInstance);
+DEFINE_EXPECT(ProcessUrlAction);
+DEFINE_EXPECT(QueryCustomPolicy);
+DEFINE_EXPECT(reportSuccess);
+DEFINE_EXPECT(Host_QS_SecMgr);
+DEFINE_EXPECT(Caller_QS_SecMgr);
+DEFINE_EXPECT(QI_IObjectWithSite);
+DEFINE_EXPECT(SetSite);
+
+static const WCHAR testW[] = {'t','e','s','t',0};
+
+static HRESULT QS_SecMgr_hres;
+static HRESULT ProcessUrlAction_hres;
+static DWORD ProcessUrlAction_policy;
+static HRESULT CreateInstance_hres;
+static HRESULT QueryCustomPolicy_hres;
+static DWORD QueryCustomPolicy_psize;
+static DWORD QueryCustomPolicy_policy;
+static HRESULT QI_IDispatch_hres;
+static HRESULT SetSite_hres;
+
+#define TESTOBJ_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80646}"
+
+static const GUID CLSID_TestObj =
+ {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
+
+/* Defined as extern in urlmon.idl, but not exported by uuid.lib */
+const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY =
+ {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
+
+#define DISPID_TEST_REPORTSUCCESS 0x1000
+
+#define DISPID_GLOBAL_OK 0x2000
+
+static const char *debugstr_guid(REFIID riid)
+{
+ static char buf[50];
+
+ sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
+ riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
+ riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
+ riid->Data4[5], riid->Data4[6], riid->Data4[7]);
+
+ return buf;
+}
+
+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;
+}
+
+static int strcmp_wa(LPCWSTR strw, const char *stra)
+{
+ CHAR buf[512];
+ WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
+ return lstrcmpA(buf, stra);
+}
+
+static HRESULT WINAPI ObjectWithSite_QueryInterface(IObjectWithSite *iface, REFIID riid,
void **ppv)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static ULONG WINAPI ObjectWithSite_AddRef(IObjectWithSite *iface)
+{
+ return 2;
+}
+
+static ULONG WINAPI ObjectWithSite_Release(IObjectWithSite *iface)
+{
+ return 1;
+}
+
+static HRESULT WINAPI ObjectWithSite_SetSite(IObjectWithSite *iface, IUnknown *pUnkSite)
+{
+ IServiceProvider *sp;
+ HRESULT hres;
+
+
+ CHECK_EXPECT(SetSite);
+ ok(pUnkSite != NULL, "pUnkSite == NULL\n");
+
+ hres = IUnknown_QueryInterface(pUnkSite, &IID_IServiceProvider,
(void**)&sp);
+ ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
+ IServiceProvider_Release(sp);
+
+ return SetSite_hres;
+}
+
+static HRESULT WINAPI ObjectWithSite_GetSite(IObjectWithSite *iface, REFIID riid, void
**ppvSite)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static const IObjectWithSiteVtbl ObjectWithSiteVtbl = {
+ ObjectWithSite_QueryInterface,
+ ObjectWithSite_AddRef,
+ ObjectWithSite_Release,
+ ObjectWithSite_SetSite,
+ ObjectWithSite_GetSite
+};
+
+static IObjectWithSite ObjectWithSite = { &ObjectWithSiteVtbl };
+
+static IObjectWithSite *object_with_site;
+
+static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void
**ppv)
+{
+ *ppv = NULL;
+
+ if(IsEqualGUID(riid, &IID_IUnknown)) {
+ *ppv = iface;
+ }else if(IsEqualGUID(riid, &IID_IDispatch) || IsEqualGUID(riid,
&IID_IDispatchEx)) {
+ if(FAILED(QI_IDispatch_hres))
+ return QI_IDispatch_hres;
+ *ppv = iface;
+ }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
+ CHECK_EXPECT(QI_IObjectWithSite);
+ *ppv = object_with_site;
+ }else {
+ return E_NOINTERFACE;
+ }
+
+ return *ppv ? S_OK : E_NOINTERFACE;
+}
+
+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)
+{
+ ok(0, "unexpected call\n");
+ 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;
+}
+
+static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName,
DWORD grfdex)
+{
+ ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
+ 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;
+}
+
+static HRESULT WINAPI Test_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex,
DISPID *pid)
+{
+ if(!strcmp_wa(bstrName, "reportSuccess")) {
+ ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ *pid = DISPID_TEST_REPORTSUCCESS;
+ return S_OK;
+ }
+
+ ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName));
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI Test_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD
wFlags, DISPPARAMS *pdp,
+ VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
+{
+ switch(id) {
+ case DISPID_TEST_REPORTSUCCESS:
+ CHECK_EXPECT(reportSuccess);
+
+ 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);
+ ok(!pvarRes, "pvarRes != NULL\n");
+ ok(pei != NULL, "pei == NULL\n");
+ break;
+
+ default:
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+ }
+
+ return S_OK;
+}
+
+static IDispatchExVtbl testObjVtbl = {
+ DispatchEx_QueryInterface,
+ DispatchEx_AddRef,
+ DispatchEx_Release,
+ DispatchEx_GetTypeInfoCount,
+ DispatchEx_GetTypeInfo,
+ DispatchEx_GetIDsOfNames,
+ DispatchEx_Invoke,
+ Test_GetDispID,
+ Test_InvokeEx,
+ DispatchEx_DeleteMemberByName,
+ DispatchEx_DeleteMemberByDispID,
+ DispatchEx_GetMemberProperties,
+ DispatchEx_GetMemberName,
+ DispatchEx_GetNextDispID,
+ DispatchEx_GetNameSpaceParent
+};
+
+static IDispatchEx testObj = { &testObjVtbl };
+
+static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex,
DISPID *pid)
+{
+ if(!strcmp_wa(bstrName, "ok")) {
+ ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ *pid = DISPID_GLOBAL_OK;
+ return S_OK;
+ }
+
+ ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName));
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD
wFlags, DISPPARAMS *pdp,
+ VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
+{
+ switch(id) {
+ case DISPID_GLOBAL_OK:
+ ok(wFlags == INVOKE_FUNC || wFlags == (INVOKE_FUNC|INVOKE_PROPERTYGET),
"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 == 2, "cArgs = %d\n", pdp->cArgs);
+ ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
+ ok(pei != NULL, "pei == NULL\n");
+
+ ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(psp->rgvargs) = %d\n",
V_VT(pdp->rgvarg));
+ ok(V_VT(pdp->rgvarg+1) == VT_BOOL, "V_VT(psp->rgvargs+1) = %d\n",
V_VT(pdp->rgvarg));
+ ok(V_BOOL(pdp->rgvarg+1), "%s\n",
wine_dbgstr_w(V_BSTR(pdp->rgvarg)));
+ break;
+
+ default:
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+ }
+
+ return S_OK;
+}
+
+static IDispatchExVtbl globalObjVtbl = {
+ DispatchEx_QueryInterface,
+ DispatchEx_AddRef,
+ DispatchEx_Release,
+ DispatchEx_GetTypeInfoCount,
+ DispatchEx_GetTypeInfo,
+ DispatchEx_GetIDsOfNames,
+ DispatchEx_Invoke,
+ Global_GetDispID,
+ Global_InvokeEx,
+ DispatchEx_DeleteMemberByName,
+ DispatchEx_DeleteMemberByDispID,
+ DispatchEx_GetMemberProperties,
+ DispatchEx_GetMemberName,
+ DispatchEx_GetNextDispID,
+ DispatchEx_GetNameSpaceParent
+};
+
+static IDispatchEx globalObj = { &globalObjVtbl };
+
+static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void
**ppv)
+{
+ if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid))
{
+ *ppv = iface;
+ return S_OK;
+ }
+
+ /* TODO: IClassFactoryEx */
+ *ppv = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
+{
+ return 2;
+}
+
+static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
+{
+ return 1;
+}
+
+static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer,
REFIID riid, void **ppv)
+{
+ CHECK_EXPECT(CreateInstance);
+
+ ok(!outer, "outer = %p\n", outer);
+ ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n",
debugstr_guid(riid));
+
+ if(SUCCEEDED(CreateInstance_hres))
+ *ppv = &testObj;
+ return CreateInstance_hres;
+}
+
+static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
+{
+ ok(0, "unexpected call\n");
+ return S_OK;
+}
+
+static const IClassFactoryVtbl ClassFactoryVtbl = {
+ ClassFactory_QueryInterface,
+ ClassFactory_AddRef,
+ ClassFactory_Release,
+ ClassFactory_CreateInstance,
+ ClassFactory_LockServer
+};
+
+static IClassFactory activex_cf = { &ClassFactoryVtbl };
+
+static HRESULT WINAPI
InternetHostSecurityManager_QueryInterface(IInternetHostSecurityManager *iface, REFIID
riid, void **ppv)
+{
+ ok(0, "unexpected call\n");
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI InternetHostSecurityManager_AddRef(IInternetHostSecurityManager
*iface)
+{
+ return 2;
+}
+
+static ULONG WINAPI InternetHostSecurityManager_Release(IInternetHostSecurityManager
*iface)
+{
+ return 1;
+}
+
+static HRESULT WINAPI
InternetHostSecurityManager_GetSecurityId(IInternetHostSecurityManager *iface, BYTE
*pbSecurityId,
+ DWORD *pcbSecurityId, DWORD_PTR dwReserved)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI
InternetHostSecurityManager_ProcessUrlAction(IInternetHostSecurityManager *iface, DWORD
dwAction,
+ BYTE *pPolicy, DWORD cbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwFlags,
DWORD dwReserved)
+{
+ CHECK_EXPECT(ProcessUrlAction);
+
+ ok(dwAction == URLACTION_ACTIVEX_RUN, "dwAction = %x\n", dwAction);
+ ok(pPolicy != NULL, "pPolicy == NULL\n");
+ ok(cbPolicy == sizeof(DWORD), "cbPolicy = %d\n", cbPolicy);
+ ok(pContext != NULL, "pContext == NULL\n");
+ ok(cbContext == sizeof(GUID), "cbContext = %d\n", cbContext);
+ ok(IsEqualGUID(pContext, &CLSID_TestObj), "pContext = %s\n",
debugstr_guid((const IID*)pContext));
+ ok(!dwFlags, "dwFlags = %x\n", dwFlags);
+ ok(!dwReserved, "dwReserved = %x\n", dwReserved);
+
+ if(SUCCEEDED(ProcessUrlAction_hres))
+ *(DWORD*)pPolicy = ProcessUrlAction_policy;
+ return ProcessUrlAction_hres;
+}
+
+static HRESULT WINAPI
InternetHostSecurityManager_QueryCustomPolicy(IInternetHostSecurityManager *iface, REFGUID
guidKey,
+ BYTE **ppPolicy, DWORD *pcbPolicy, BYTE *pContext, DWORD cbContext, DWORD
dwReserved)
+{
+ const struct CONFIRMSAFETY *cs = (const struct CONFIRMSAFETY*)pContext;
+ DWORD *ret;
+
+ CHECK_EXPECT(QueryCustomPolicy);
+
+ ok(IsEqualGUID(&GUID_CUSTOM_CONFIRMOBJECTSAFETY, guidKey), "guidKey =
%s\n", debugstr_guid(guidKey));
+
+ ok(ppPolicy != NULL, "ppPolicy == NULL\n");
+ ok(pcbPolicy != NULL, "pcbPolicy == NULL\n");
+ ok(pContext != NULL, "pContext == NULL\n");
+ ok(cbContext == sizeof(struct CONFIRMSAFETY), "cbContext = %d\n",
cbContext);
+ ok(!dwReserved, "dwReserved = %x\n", dwReserved);
+
+ /* TODO: CLSID */
+ ok(cs->pUnk != NULL, "cs->pUnk == NULL\n");
+ ok(!cs->dwFlags, "dwFlags = %x\n", cs->dwFlags);
+
+ if(FAILED(QueryCustomPolicy_hres))
+ return QueryCustomPolicy_hres;
+
+ ret = CoTaskMemAlloc(QueryCustomPolicy_psize);
+ *ppPolicy = (BYTE*)ret;
+ *pcbPolicy = QueryCustomPolicy_psize;
+ memset(ret, 0, QueryCustomPolicy_psize);
+ if(QueryCustomPolicy_psize >= sizeof(DWORD))
+ *ret = QueryCustomPolicy_policy;
+
+ return QueryCustomPolicy_hres;
+}
+
+static const IInternetHostSecurityManagerVtbl InternetHostSecurityManagerVtbl = {
+ InternetHostSecurityManager_QueryInterface,
+ InternetHostSecurityManager_AddRef,
+ InternetHostSecurityManager_Release,
+ InternetHostSecurityManager_GetSecurityId,
+ InternetHostSecurityManager_ProcessUrlAction,
+ InternetHostSecurityManager_QueryCustomPolicy
+};
+
+static IInternetHostSecurityManager InternetHostSecurityManager = {
&InternetHostSecurityManagerVtbl };
+
+static IServiceProvider ServiceProvider;
+
+static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID
riid, void **ppv)
+{
+ ok(0, "unexpected call\n");
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
+{
+ return 2;
+}
+
+static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
+{
+ return 1;
+}
+
+static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
+ REFGUID guidService, REFIID riid, void **ppv)
+{
+ if(IsEqualGUID(&SID_GetCaller, guidService))
+ return E_NOINTERFACE;
+
+ if(IsEqualGUID(&SID_SInternetHostSecurityManager, guidService)) {
+ if(iface == &ServiceProvider)
+ CHECK_EXPECT(Host_QS_SecMgr);
+ else
+ CHECK_EXPECT(Caller_QS_SecMgr);
+ ok(IsEqualGUID(&IID_IInternetHostSecurityManager, riid), "unexpected
riid %s\n", debugstr_guid(riid));
+ if(SUCCEEDED(QS_SecMgr_hres))
+ *ppv = &InternetHostSecurityManager;
+ return QS_SecMgr_hres;
+ }
+
+ ok(0, "unexpected service %s\n", debugstr_guid(guidService));
+ return E_NOINTERFACE;
+}
+
+static IServiceProviderVtbl ServiceProviderVtbl = {
+ ServiceProvider_QueryInterface,
+ ServiceProvider_AddRef,
+ ServiceProvider_Release,
+ ServiceProvider_QueryService
+};
+
+static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
+static IServiceProvider caller_sp = { &ServiceProviderVtbl };
+
+static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID
riid, void **ppv)
+{
+ if(IsEqualGUID(&IID_IUnknown, riid)) {
+ *ppv = iface;
+ }else if(IsEqualGUID(&IID_IActiveScriptSite, riid)) {
+ *ppv = iface;
+ }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
+ *ppv = &ServiceProvider;
+ }else {
+ *ppv = NULL;
+ 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");
+ ok(!strcmp_wa(pstrName, "test"), "pstrName = %s\n",
wine_dbgstr_w(pstrName));
+
+ *ppiunkItem = (IUnknown*)&globalObj;
+ 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 };
+
+static void set_safety_options(IUnknown *unk)
+{
+ IObjectSafety *safety;
+ DWORD supported, enabled;
+ HRESULT hres;
+
+ hres = IUnknown_QueryInterface(unk, &IID_IObjectSafety, (void**)&safety);
+ ok(hres == S_OK, "Could not get IObjectSafety: %08x\n", hres);
+ if(FAILED(hres))
+ return;
+
+ hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
+
INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER,
+
INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER);
+ ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
+
+ supported = enabled = 0xdeadbeef;
+ hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
&supported, &enabled);
+ ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
+ ok(supported ==
(INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
+ "supported=%x\n", supported);
+ ok(enabled ==
(INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
+ "enabled=%x\n", enabled);
+
+ IObjectSafety_Release(safety);
+}
+
+#define parse_script_a(p,s) _parse_script_a(__LINE__,p,s)
+static void _parse_script_a(unsigned line, IActiveScriptParse *parser, const char
*script)
+{
+ BSTR str;
+ HRESULT hres;
+
+ str = a2bstr(script);
+ hres = IActiveScriptParse64_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0,
NULL, NULL);
+ SysFreeString(str);
+ ok_(__FILE__,line)(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
+}
+
+static IActiveScriptParse *create_script(void)
+{
+ IActiveScriptParse *parser;
+ IActiveScript *script;
+ HRESULT hres;
+
+ QS_SecMgr_hres = S_OK;
+ ProcessUrlAction_hres = S_OK;
+ ProcessUrlAction_policy = URLPOLICY_ALLOW;
+ CreateInstance_hres = S_OK;
+ QueryCustomPolicy_hres = S_OK;
+ QueryCustomPolicy_psize = sizeof(DWORD);
+ QueryCustomPolicy_policy = URLPOLICY_ALLOW;
+ QI_IDispatch_hres = S_OK;
+ SetSite_hres = S_OK;
+
+ hres = CoCreateInstance(&CLSID_JScript, NULL,
CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
+ &IID_IActiveScript, (void**)&script);
+ ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
+ if(FAILED(hres))
+ return NULL;
+
+ set_safety_options((IUnknown*)script);
+
+ hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse,
(void**)&parser);
+ ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
+
+ hres = IActiveScriptParse64_InitNew(parser);
+ ok(hres == S_OK, "InitNew failed: %08x\n", hres);
+
+ hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
+ ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
+
+ hres = IActiveScript_AddNamedItem(script, testW,
+ SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
+ ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
+
+ hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED);
+ ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n",
hres);
+
+ IActiveScript_Release(script);
+
+ parse_script_a(parser,
+ "function testException(func, type, number) {\n"
+ "try {\n"
+ " func();\n"
+ "}catch(e) {\n"
+ " ok(e.name === type, 'e.name = ' + e.name + ', expected
' + type)\n"
+ " ok(e.number === number, 'e.number = ' + e.number + ',
expected ' + number);\n"
+ " return;\n"
+ "}"
+ "ok(false, 'exception expected');\n"
+ "}");
+
+ return parser;
+}
+
+static IDispatchEx *parse_procedure_a(IActiveScriptParse *parser, const char *src)
+{
+ IActiveScriptParseProcedure2 *parse_proc;
+ IDispatchEx *dispex;
+ IDispatch *disp;
+ BSTR str;
+ HRESULT hres;
+
+ hres = IUnknown_QueryInterface(parser, &IID_IActiveScriptParseProcedure2,
(void**)&parse_proc);
+ ok(hres == S_OK, "Coult not get IActiveScriptParseProcedure2: %08x\n",
hres);
+
+ str = a2bstr(src);
+ hres = IActiveScriptParseProcedure2_64_ParseProcedureText(parse_proc, str, NULL,
NULL, NULL, NULL, NULL, 0, 0, 0, &disp);
+ SysFreeString(str);
+ IUnknown_Release(parse_proc);
+ ok(hres == S_OK, "ParseProcedureText failed: %08x\n", hres);
+ ok(disp != NULL, "disp == NULL\n");
+
+ hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
+ IDispatch_Release(dispex);
+ ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
+
+ return dispex;
+}
+
+#define call_procedure(p,c) _call_procedure(__LINE__,p,c)
+static void _call_procedure(unsigned line, IDispatchEx *proc, IServiceProvider *caller)
+{
+ DISPPARAMS dp = {NULL,NULL,0,0};
+ EXCEPINFO ei = {0};
+ HRESULT hres;
+
+ hres = IDispatchEx_InvokeEx(proc, DISPID_VALUE, 0, DISPATCH_METHOD, &dp, NULL,
&ei, caller);
+ ok_(__FILE__,line)(hres == S_OK, "InvokeEx failed: %08x\n", hres);
+
+}
+
+static void test_ActiveXObject(void)
+{
+ IActiveScriptParse *parser;
+ IDispatchEx *proc;
+
+ parser = create_script();
+
+ SET_EXPECT(Host_QS_SecMgr);
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ SET_EXPECT(QI_IObjectWithSite);
+ SET_EXPECT(reportSuccess);
+ parse_script_a(parser, "(new
ActiveXObject('Wine.Test')).reportSuccess();");
+ CHECK_CALLED(Host_QS_SecMgr);
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+ CHECK_CALLED(QI_IObjectWithSite);
+ CHECK_CALLED(reportSuccess);
+
+ proc = parse_procedure_a(parser, "(new
ActiveXObject('Wine.Test')).reportSuccess();");
+
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ SET_EXPECT(QI_IObjectWithSite);
+ SET_EXPECT(reportSuccess);
+ call_procedure(proc, NULL);
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+ CHECK_CALLED(QI_IObjectWithSite);
+ CHECK_CALLED(reportSuccess);
+
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ SET_EXPECT(QI_IObjectWithSite);
+ SET_EXPECT(reportSuccess);
+ call_procedure(proc, &caller_sp);
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+ CHECK_CALLED(QI_IObjectWithSite);
+ CHECK_CALLED(reportSuccess);
+
+ IDispatchEx_Release(proc);
+ IUnknown_Release(parser);
+
+ parser = create_script();
+ proc = parse_procedure_a(parser, "(new
ActiveXObject('Wine.Test')).reportSuccess();");
+
+ SET_EXPECT(Host_QS_SecMgr);
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ SET_EXPECT(QI_IObjectWithSite);
+ SET_EXPECT(reportSuccess);
+ call_procedure(proc, &caller_sp);
+ CHECK_CALLED(Host_QS_SecMgr);
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+ CHECK_CALLED(QI_IObjectWithSite);
+ CHECK_CALLED(reportSuccess);
+
+ parse_script_a(parser, "testException(function() { new
ActiveXObject('Wine.TestABC'); }, 'Error', -2146827859);");
+
+ IDispatchEx_Release(proc);
+ IUnknown_Release(parser);
+
+ parser = create_script();
+ QS_SecMgr_hres = E_NOINTERFACE;
+
+ SET_EXPECT(Host_QS_SecMgr);
+ parse_script_a(parser, "testException(function() { new
ActiveXObject('Wine.Test'); }, 'Error', -2146827859);");
+ CHECK_CALLED(Host_QS_SecMgr);
+
+ IUnknown_Release(parser);
+
+ parser = create_script();
+ ProcessUrlAction_hres = E_FAIL;
+
+ SET_EXPECT(Host_QS_SecMgr);
+ SET_EXPECT(ProcessUrlAction);
+ parse_script_a(parser, "testException(function() { new
ActiveXObject('Wine.Test'); }, 'Error', -2146827859);");
+ CHECK_CALLED(Host_QS_SecMgr);
+ CHECK_CALLED(ProcessUrlAction);
+
+ IUnknown_Release(parser);
+
+ parser = create_script();
+ ProcessUrlAction_policy = URLPOLICY_DISALLOW;
+
+ SET_EXPECT(Host_QS_SecMgr);
+ SET_EXPECT(ProcessUrlAction);
+ parse_script_a(parser, "testException(function() { new
ActiveXObject('Wine.Test'); }, 'Error', -2146827859);");
+ CHECK_CALLED(Host_QS_SecMgr);
+ CHECK_CALLED(ProcessUrlAction);
+
+ IUnknown_Release(parser);
+
+ parser = create_script();
+ CreateInstance_hres = E_FAIL;
+
+ SET_EXPECT(Host_QS_SecMgr);
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ parse_script_a(parser, "testException(function() { new
ActiveXObject('Wine.Test'); }, 'Error', -2146827859);");
+ CHECK_CALLED(Host_QS_SecMgr);
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+
+ IUnknown_Release(parser);
+
+ parser = create_script();
+ QueryCustomPolicy_hres = E_FAIL;
+
+ SET_EXPECT(Host_QS_SecMgr);
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ parse_script_a(parser, "testException(function() { new
ActiveXObject('Wine.Test'); }, 'Error', -2146827859);");
+ CHECK_CALLED(Host_QS_SecMgr);
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+
+ IUnknown_Release(parser);
+
+ parser = create_script();
+ QueryCustomPolicy_psize = 6;
+
+ SET_EXPECT(Host_QS_SecMgr);
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ SET_EXPECT(QI_IObjectWithSite);
+ SET_EXPECT(reportSuccess);
+ parse_script_a(parser, "(new
ActiveXObject('Wine.Test')).reportSuccess();");
+ CHECK_CALLED(Host_QS_SecMgr);
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+ CHECK_CALLED(QI_IObjectWithSite);
+ CHECK_CALLED(reportSuccess);
+
+ IUnknown_Release(parser);
+
+ parser = create_script();
+ QueryCustomPolicy_policy = URLPOLICY_DISALLOW;
+
+ SET_EXPECT(Host_QS_SecMgr);
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ parse_script_a(parser, "testException(function() { new
ActiveXObject('Wine.Test'); }, 'Error', -2146827859);");
+ CHECK_CALLED(Host_QS_SecMgr);
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+
+ QueryCustomPolicy_psize = 6;
+
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ parse_script_a(parser, "testException(function() { new
ActiveXObject('Wine.Test'); }, 'Error', -2146827859);");
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+
+ QueryCustomPolicy_policy = URLPOLICY_ALLOW;
+ QueryCustomPolicy_psize = 3;
+
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ parse_script_a(parser, "testException(function() { new
ActiveXObject('Wine.Test'); }, 'Error', -2146827859);");
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+
+ IUnknown_Release(parser);
+
+ parser = create_script();
+ object_with_site = &ObjectWithSite;
+
+ SET_EXPECT(Host_QS_SecMgr);
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ SET_EXPECT(QI_IObjectWithSite);
+ SET_EXPECT(SetSite);
+ SET_EXPECT(reportSuccess);
+ parse_script_a(parser, "(new
ActiveXObject('Wine.Test')).reportSuccess();");
+ CHECK_CALLED(Host_QS_SecMgr);
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+ CHECK_CALLED(QI_IObjectWithSite);
+ CHECK_CALLED(SetSite);
+ CHECK_CALLED(reportSuccess);
+
+ SetSite_hres = E_FAIL;
+ SET_EXPECT(ProcessUrlAction);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(QueryCustomPolicy);
+ SET_EXPECT(QI_IObjectWithSite);
+ SET_EXPECT(SetSite);
+ parse_script_a(parser, "testException(function() { new
ActiveXObject('Wine.Test'); }, 'Error', -2146827859);");
+ CHECK_CALLED(ProcessUrlAction);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(QueryCustomPolicy);
+ CHECK_CALLED(QI_IObjectWithSite);
+ CHECK_CALLED(SetSite);
+
+ IUnknown_Release(parser);
+}
+
+static BOOL init_key(const char *key_name, const char *def_value, BOOL init)
+{
+ HKEY hkey;
+ DWORD res;
+
+ if(!init) {
+ RegDeleteKey(HKEY_CLASSES_ROOT, key_name);
+ return TRUE;
+ }
+
+ res = RegCreateKeyA(HKEY_CLASSES_ROOT, key_name, &hkey);
+ if(res != ERROR_SUCCESS)
+ return FALSE;
+
+ if(def_value)
+ res = RegSetValueA(hkey, NULL, REG_SZ, def_value, strlen(def_value));
+
+ RegCloseKey(hkey);
+
+ return res == ERROR_SUCCESS;
+}
+
+static BOOL init_registry(BOOL init)
+{
+ return init_key("Wine.Test\\CLSID", TESTOBJ_CLSID, init);
+}
+
+static BOOL register_activex(void)
+{
+ DWORD regid;
+ HRESULT hres;
+
+ if(!init_registry(TRUE)) {
+ init_registry(FALSE);
+ return FALSE;
+ }
+
+ hres = CoRegisterClassObject(&CLSID_TestObj, (IUnknown *)&activex_cf,
+ CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id);
+ ok(hres == S_OK, "Could not register screipt engine: %08x\n", hres);
+
+ return TRUE;
+}
+
+static BOOL check_jscript(void)
+{
+ IActiveScriptParse *parser;
+ BSTR str;
+ HRESULT hres;
+
+ parser = create_script();
+ if(!parser)
+ return FALSE;
+
+ str = a2bstr("if(!('localeCompare' in String.prototype)) throw
1;");
+ hres = IActiveScriptParse64_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0,
NULL, NULL);
+ SysFreeString(str);
+ IUnknown_Release(parser);
+
+ return hres == S_OK;
+}
+
+START_TEST(activex)
+{
+ CoInitialize(NULL);
+
+ if(check_jscript()) {
+ register_activex();
+
+ test_ActiveXObject();
+
+ init_registry(FALSE);
+ }else {
+ win_skip("Broken engine, probably too old\n");
+ }
+
+ CoUninitialize();
+}
Propchange: trunk/rostests/winetests/jscript/activex.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/winetests/jscript/api.js
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/jscript/api.js?…
==============================================================================
--- trunk/rostests/winetests/jscript/api.js [iso-8859-1] (original)
+++ trunk/rostests/winetests/jscript/api.js [iso-8859-1] Tue Mar 2 20:52:22 2010
@@ -57,6 +57,47 @@
ok(tmp === "undefined", "encodeURI() = " + tmp);
tmp = encodeURI("abc", "test");
ok(tmp === "abc", "encodeURI('abc') = " + tmp);
+
+tmp = encodeURIComponent("abc");
+ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
+dec = decodeURIComponent(tmp);
+ok(dec === "abc", "decodeURIComponent('" + tmp + "') =
" + dec);
+tmp = encodeURIComponent("{abc}");
+ok(tmp === "%7Babc%7D", "encodeURIComponent('{abc}') = " +
tmp);
+dec = decodeURIComponent(tmp);
+ok(dec === "{abc}", "decodeURIComponent('" + tmp + "') =
" + dec);
+tmp = encodeURIComponent("");
+ok(tmp === "", "encodeURIComponent('') = " + tmp);
+dec = decodeURIComponent(tmp);
+ok(dec === "", "decodeURIComponent('" + tmp + "') =
" + dec);
+tmp = encodeURIComponent("\01\02\03\04");
+ok(tmp === "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04')
= " + tmp);
+dec = decodeURIComponent(tmp);
+ok(dec === "\01\02\03\04", "decodeURIComponent('" + tmp +
"') = " + dec);
+tmp = encodeURIComponent("{#@}");
+ok(tmp === "%7B%23%40%7D", "encodeURIComponent('{#@}') = " +
tmp);
+dec = decodeURIComponent(tmp);
+ok(dec === "{#@}", "decodeURIComponent('" + tmp + "') =
" + dec);
+tmp = encodeURIComponent("\xa1 ");
+ok(tmp === "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp);
+dec = decodeURIComponent(tmp);
+ok(dec === "\xa1 ", "decodeURIComponent('" + tmp + "') =
" + dec);
+tmp = encodeURIComponent("\xffff");
+ok(tmp.length === 8, "encodeURIComponent('\\xffff').length = " +
tmp.length);
+dec = decodeURIComponent(tmp);
+ok(dec === "\xffff", "decodeURIComponent('" + tmp + "')
= " + dec);
+tmp = encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()");
+ok(tmp === "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()",
"encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
+dec = decodeURIComponent(tmp);
+ok(dec === "abcABC123;/?:@&=+$,-_.!~*'()",
"decodeURIComponent('" + tmp + "') = " + dec);
+tmp = encodeURIComponent();
+ok(tmp === "undefined", "encodeURIComponent() = " + tmp);
+tmp = encodeURIComponent("abc", "test");
+ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
+dec = decodeURIComponent();
+ok(dec === "undefined", "decodeURIComponent() = " + dec);
+dec = decodeURIComponent("abc", "test");
+ok(dec === "abc", "decodeURIComponent('abc') = " + dec);
tmp = escape("abc");
ok(tmp === "abc", "escape('abc') = " + tmp);
@@ -190,6 +231,8 @@
ok(tmp === "", "'abc',charAt(-1) = " + tmp);
tmp = "abc".charAt(0,2);
ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
+tmp = "abc".charAt(NaN);
+ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
tmp = "abc".charCodeAt(0);
ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
@@ -575,6 +618,12 @@
ok(arr[8] === "b", "arr[8] != 'b'");
ok(arr.length === 10, "arr.length != 10");
+arr.pop = Array.prototype.pop;
+ok(arr.pop() === false, "arr.pop() !== false");
+ok(arr[8] === "b", "arr[8] !== 'b'");
+ok(arr.pop() === 'b', "arr.pop() !== 'b'");
+ok(arr[8] === undefined, "arr[8] !== undefined");
+
arr = [3,4,5];
tmp = arr.pop();
ok(arr.length === 2, "arr.length = " + arr.length);
@@ -590,6 +639,11 @@
tmp = arr.pop();
ok(arr.length === 0, "arr.length = " + arr.length);
ok(tmp === undefined, "tmp = " + tmp);
+arr = new Object();
+arr.pop = Array.prototype.pop;
+tmp = arr.pop();
+ok(arr.length === 0, "arr.length = " + arr.length);
+ok(tmp === undefined, "tmp = " + tmp);
arr = [,,,,,];
tmp = arr.pop();
ok(arr.length === 5, "arr.length = " + arr.length);
@@ -611,6 +665,16 @@
tmp = arr.toString("test");
ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
+arr = new Object();
+arr.length = 3;
+arr[0] = "aa";
+arr[2] = 2;
+arr[7] = 3;
+arr.join = Array.prototype.join;
+tmp = arr.join(",");
+ok(arr.length === 3, "arr.length = " + arr.length);
+ok(tmp === "aa,,2", "tmp = " + tmp);
+
arr = [5,true,2,-1,3,false,"2.5"];
tmp = arr.sort(function(x,y) { return y-x; });
ok(tmp === arr, "tmp !== arr");
@@ -631,6 +695,15 @@
for(var i=0; i < arr.length; i++)
ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + "
expected " + tmp[i]);
+arr = new Object();
+arr.length = 3;
+arr[0] = 1;
+arr[2] = "aa";
+arr.sort = Array.prototype.sort;
+tmp = arr.sort();
+ok(arr === tmp, "tmp !== arr");
+ok(arr[0]===1 && arr[1]==="aa" && arr[2]===undefined, "arr
is sorted incorectly");
+
arr = ["1", "2", "3"];
arr.length = 1;
ok(arr.length === 1, "arr.length = " + arr.length);
@@ -645,8 +718,33 @@
ok(arr === arr.valueOf(), "arr !== arr.valueOf");
arr = [1,2,3];
+tmp = arr.reverse();
+ok(tmp === arr, "tmp !== arr");
+ok(arr.length === 3, "arr.length = " + arr.length);
+ok(arr.toString() === "3,2,1", "arr.toString() = " +
arr.toString());
+
+arr = [];
+arr[3] = 5;
+arr[5] = 1;
+tmp = arr.reverse();
+ok(tmp === arr, "tmp !== arr");
+ok(arr.length === 6, "arr.length = " + arr.length);
+ok(arr.toString() === "1,,5,,,", "arr.toString() = " +
arr.toString());
+
+arr = new Object();
+arr.length = 3;
+arr[0] = "aa";
+arr[2] = 2;
+arr[7] = 3;
+arr.reverse = Array.prototype.reverse;
+tmp = arr.reverse();
+ok(tmp === arr, "tmp !== arr");
+ok(arr.length === 3, "arr.length = " + arr.length);
+ok(arr[0] === 2 && arr[1] === undefined && arr[2] === "aa",
"unexpected array");
+
+arr = [1,2,3];
tmp = arr.unshift(0);
-ok(tmp === undefined, "[1,2,3].unshift(0) returned " +tmp);
+ok(tmp === (invokeVersion < 2 ? undefined : 4), "[1,2,3].unshift(0) returned
" +tmp);
ok(arr.length === 4, "arr.length = " + arr.length);
ok(arr.toString() === "0,1,2,3", "arr.toString() = " +
arr.toString());
@@ -654,13 +752,13 @@
arr[0] = 1;
arr[2] = 3;
tmp = arr.unshift(-1,0);
-ok(tmp === undefined, "unshift returned " +tmp);
+ok(tmp === (invokeVersion < 2 ? undefined : 5), "unshift returned " +tmp);
ok(arr.length === 5, "arr.length = " + arr.length);
ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " +
arr.toString());
arr = [1,2,3];
tmp = arr.unshift();
-ok(tmp === undefined, "unshift returned " +tmp);
+ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
ok(arr.length === 3, "arr.length = " + arr.length);
ok(arr.toString() === "1,2,3", "arr.toString() = " +
arr.toString());
@@ -669,7 +767,7 @@
arr[0] = 1;
arr[1] = 2;
tmp = Array.prototype.unshift.call(arr, 0);
-ok(tmp === undefined, "unshift returned " +tmp);
+ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
ok(arr.length === 3, "arr.length = " + arr.length);
ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected
array");
@@ -1374,13 +1472,64 @@
(function () { callTest2.apply(tmp, arguments); })();
function callTest3() {
+ testThis(this);
ok(arguments.length === 0, "arguments.length = " + arguments.length +
" expected 0");
}
callTest3.call();
+callTest3.call(undefined);
+callTest3.call(null);
+callTest3.apply();
+callTest3.apply(undefined);
+callTest3.apply(null);
tmp = Number.prototype.toString.call(3);
ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
+
+var func = new Function("return 3;");
+
+tmp = func();
+ok(tmp === 3, "func() = " + tmp);
+ok(func.call() === 3, "func.call() = " + tmp);
+ok(func.length === 0, "func.length = " + func.length);
+tmp = func.toString();
+ok(tmp === "function anonymous() {\nreturn 3;\n}", "func.toString() =
" + tmp);
+
+func = new Function("x", "return x+2;");
+tmp = func(1);
+ok(tmp === 3, "func(1) = " + tmp);
+tmp = func.toString();
+ok(tmp === "function anonymous(x) {\nreturn x+2;\n}", "func.toString() =
" + tmp);
+
+tmp = (new Function("x ", "return x+2;")).toString();
+ok(tmp === "function anonymous(x ) {\nreturn x+2;\n}", "func.toString() =
" + tmp);
+
+func = new Function("x", "y", "return x+y");
+tmp = func(1,3);
+ok(tmp === 4, "func(1,3) = " + tmp);
+tmp = func.toString();
+ok(tmp === "function anonymous(x, y) {\nreturn x+y\n}", "func.toString() =
" + tmp);
+
+func = new Function(" x, \ty", "\tz", "return x+y+z;");
+tmp = func(1,3,2);
+ok(tmp === 6, "func(1,3,2) = " + tmp);
+ok(func.length === 3, "func.length = " + func.length);
+tmp = func.toString();
+ok(tmp === "function anonymous( x, \ty, \tz) {\nreturn x+y+z;\n}",
"func.toString() = " + tmp);
+
+func = new Function();
+tmp = func();
+ok(tmp === undefined, "func() = " + tmp);
+tmp = func.toString();
+ok(tmp == "function anonymous() {\n\n}", "func.toString() = " +
tmp);
+
+func = (function() {
+ var tmp = 3;
+ return new Function("return tmp;");
+ })();
+tmp = 2;
+tmp = func();
+ok(tmp === 2, "func() = " + tmp);
var date = new Date();
@@ -1566,7 +1715,7 @@
ok(err.name === "Error", "err.name = " + err.name);
EvalError.prototype.message = "test";
ok(err.toString !== Object.prototype.toString, "err.toString ===
Object.prototype.toString");
-ok(err.toString() === "[object Error]", "err.toString() = " +
err.toString());
+ok(err.toString() === (invokeVersion < 2 ? "[object Error]" :
"Error"), "err.toString() = " + err.toString());
err = new EvalError();
ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name =
" + EvalError.prototype.name);
ok(err.name === "EvalError", "err.name = " + err.name);
@@ -1574,37 +1723,67 @@
ok(err.message === "", "err.message != ''");
err.message = date;
ok(err.message === date, "err.message != date");
-ok(err.toString() === "[object Error]", "err.toString() = " +
err.toString());
+ok(err.toString() === (invokeVersion < 2 ? "[object Error]" :
"EvalError: "+err.message),
+ "err.toString() = " + err.toString());
ok(err.toString !== Object.prototype.toString, "err.toString ===
Object.prototype.toString");
err = new RangeError();
ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name
= " + RangeError.prototype.name);
ok(err.name === "RangeError", "err.name = " + err.name);
-ok(err.toString() === "[object Error]", "err.toString() = " +
err.toString());
+ok(err.toString() === (invokeVersion < 2 ? "[object Error]" :
"RangeError"), "err.toString() = " + err.toString());
err = new ReferenceError();
ok(ReferenceError.prototype.name === "ReferenceError",
"ReferenceError.prototype.name = " + ReferenceError.prototype.name);
ok(err.name === "ReferenceError", "err.name = " + err.name);
-ok(err.toString() === "[object Error]", "err.toString() = " +
err.toString());
+ok(err.toString() === (invokeVersion < 2 ? "[object Error]" :
"ReferenceError"), "err.toString() = " + err.toString());
err = new SyntaxError();
ok(SyntaxError.prototype.name === "SyntaxError",
"SyntaxError.prototype.name = " + SyntaxError.prototype.name);
ok(err.name === "SyntaxError", "err.name = " + err.name);
-ok(err.toString() === "[object Error]", "err.toString() = " +
err.toString());
+ok(err.toString() === (invokeVersion < 2 ? "[object Error]" :
"SyntaxError"), "err.toString() = " + err.toString());
err = new TypeError();
ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name =
" + TypeError.prototype.name);
ok(err.name === "TypeError", "err.name = " + err.name);
-ok(err.toString() === "[object Error]", "err.toString() = " +
err.toString());
+ok(err.toString() === (invokeVersion < 2 ? "[object Error]" :
"TypeError"), "err.toString() = " + err.toString());
err = new URIError();
ok(URIError.prototype.name === "URIError", "URIError.prototype.name =
" + URIError.prototype.name);
ok(err.name === "URIError", "err.name = " + err.name);
-ok(err.toString() === "[object Error]", "err.toString() = " +
err.toString());
+ok(err.toString() === (invokeVersion < 2 ? "[object Error]" :
"URIError"), "err.toString() = " + err.toString());
err = new Error("message");
ok(err.message === "message", "err.message !== 'message'");
-ok(err.toString() === "[object Error]", "err.toString() = " +
err.toString());
+ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error:
message"), "err.toString() = " + err.toString());
err = new Error(123);
ok(err.number === 123, "err.number = " + err.number);
err = new Error(0, "message");
ok(err.number === 0, "err.number = " + err.number);
ok(err.message === "message", "err.message = " + err.message);
ok(err.description === "message", "err.description = " +
err.description);
+
+tmp = new Object();
+tmp.toString = function() { return "test"; };
+
+tmp = Error.prototype.toString.call(tmp);
+ok(tmp === "[object Error]", "Error.prototype.toString.call(tmp) = "
+ tmp);
+
+err = new Error();
+err.name = null;
+ok(err.name === null, "err.name = " + err.name + " expected null");
+if(invokeVersion >= 2)
+ ok(err.toString() === "null", "err.toString() = " +
err.toString());
+
+err = new Error();
+err.message = false;
+ok(err.message === false, "err.message = " + err.message + " expected
false");
+if(invokeVersion >= 2)
+ ok(err.toString() === "Error: false", "err.toString() = " +
err.toString());
+
+err = new Error();
+err.message = new Object();
+err.message.toString = function() { return ""; };
+if(invokeVersion >= 2)
+ ok(err.toString() === "Error", "err.toString() = " +
err.toString());
+
+err = new Error();
+err.message = undefined;
+if(invokeVersion >= 2)
+ ok(err.toString() === "Error", "err.toString() = " +
err.toString());
function exception_test(func, type, number) {
ret = "";
@@ -1648,6 +1827,7 @@
exception_test(function() {eval("'unterminated")}, "SyntaxError",
-2146827273);
exception_test(function() {eval("nonexistingfunc()")}, "TypeError",
-2146823281);
exception_test(function() {RegExp(/a/, "g");}, "RegExpError",
-2146823271);
+exception_test(function() {encodeURI('\udcaa');}, "URIError",
-2146823264);
function testThisExcept(func, number) {
exception_test(function() {func.call(new Object())}, "TypeError", number);
@@ -1729,6 +1909,10 @@
testArrayHostThis("slice");
testArrayHostThis("splice");
testArrayHostThis("unshift");
+testArrayHostThis("reverse");
+testArrayHostThis("join");
+testArrayHostThis("pop");
+testArrayHostThis("sort");
function testObjectInherit(obj, constr, ts, tls, vo) {
ok(obj instanceof Object, "obj is not instance of Object");
@@ -1941,4 +2125,43 @@
["toString", 0]
]);
+ok(ActiveXObject.length == 1, "ActiveXObject.length = " +
ActiveXObject.length);
+ok(Array.length == 1, "Array.length = " + Array.length);
+ok(Boolean.length == 1, "Boolean.length = " + Boolean.length);
+ok(CollectGarbage.length == 0, "CollectGarbage.length = " +
CollectGarbage.length);
+//ok(Date.length == 7, "Date.length = " + Date.length);
+ok(Enumerator.length == 7, "Enumerator.length = " + Enumerator.length);
+ok(Error.length == 1, "Error.length = " + Error.length);
+ok(EvalError.length == 1, "EvalError.length = " + EvalError.length);
+ok(Function.length == 1, "Function.length = " + Function.length);
+ok(GetObject.length == 2, "GetObject.length = " + GetObject.length);
+ok(Number.length == 1, "Number.length = " + Number.length);
+ok(Object.length == 0, "Object.length = " + Object.length);
+ok(RangeError.length == 1, "RangeError.length = " + RangeError.length);
+ok(ReferenceError.length == 1, "ReferenceError.length = " +
ReferenceError.length);
+ok(RegExp.length == 2, "RegExp.length = " + RegExp.length);
+ok(ScriptEngine.length == 0, "ScriptEngine.length = " + ScriptEngine.length);
+ok(ScriptEngineBuildVersion.length == 0,
+ "ScriptEngineBuildVersion.length = " + ScriptEngineBuildVersion.length);
+ok(ScriptEngineMajorVersion.length == 0,
+ "ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion.length);
+ok(ScriptEngineMinorVersion.length == 0,
+ "ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion.length);
+//ok(String.length == 1, "String.length = " + String.length);
+ok(SyntaxError.length == 1, "SyntaxError.length = " + SyntaxError.length);
+ok(TypeError.length == 1, "TypeError.length = " + TypeError.length);
+ok(URIError.length == 1, "URIError.length = " + URIError.length);
+ok(VBArray.length == 1, "VBArray.length = " + VBArray.length);
+ok(decodeURI.length == 1, "decodeURI.length = " + decodeURI.length);
+ok(decodeURIComponent.length == 1, "decodeURIComponent.length = " +
decodeURIComponent.length);
+ok(encodeURI.length == 1, "encodeURI.length = " + encodeURI.length);
+ok(encodeURIComponent.length == 1, "encodeURIComponent.length = " +
encodeURIComponent.length);
+ok(escape.length == 1, "escape.length = " + escape.length);
+ok(eval.length == 1, "eval.length = " + eval.length);
+ok(isFinite.length == 1, "isFinite.length = " + isFinite.length);
+ok(isNaN.length == 1, "isNaN.length = " + isNaN.length);
+ok(parseFloat.length == 1, "parseFloat.length = " + parseFloat.length);
+ok(parseInt.length == 2, "parseInt.length = " + parseInt.length);
+ok(unescape.length == 1, "unescape.length = " + unescape.length);
+
reportSuccess();
Modified: trunk/rostests/winetests/jscript/jscript.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/jscript/jscript…
==============================================================================
--- trunk/rostests/winetests/jscript/jscript.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/jscript/jscript.c [iso-8859-1] Tue Mar 2 20:52:22 2010
@@ -203,37 +203,70 @@
static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl };
-static void test_script_dispatch(IActiveScript *script, BOOL initialized)
-{
- IDispatchEx *dispex;
- IDispatch *disp;
+static void test_script_dispatch(IDispatchEx *dispex)
+{
+ DISPPARAMS dp = {NULL,NULL,0,0};
+ EXCEPINFO ei;
BSTR str;
DISPID id;
- HRESULT hres;
-
- disp = (void*)0xdeadbeef;
- hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
- if(!initialized) {
- ok(hres == E_UNEXPECTED, "hres = %08x, expected E_UNEXPECTED\n",
hres);
- ok(!disp, "disp != NULL\n");
- return;
- }
-
- ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
- if(FAILED(hres))
- return;
-
- ok(disp != NULL, "disp == NULL\n");
- hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
- IDispatch_Release(disp);
- ok(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
+ VARIANT v;
+ HRESULT hres;
str = a2bstr("ActiveXObject");
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
SysFreeString(str);
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
- IDispatchEx_Release(dispex);
+ str = a2bstr("Math");
+ hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
+ SysFreeString(str);
+ ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
+
+ memset(&ei, 0, sizeof(ei));
+ hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &v,
&ei, NULL);
+ ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
+ ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+ ok(V_DISPATCH(&v) != NULL, "V_DISPATCH(v) = NULL\n");
+ VariantClear(&v);
+
+ str = a2bstr("String");
+ hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
+ SysFreeString(str);
+ ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
+
+ memset(&ei, 0, sizeof(ei));
+ hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &v,
&ei, NULL);
+ ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
+ ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+ ok(V_DISPATCH(&v) != NULL, "V_DISPATCH(v) = NULL\n");
+ VariantClear(&v);
+}
+
+static IDispatchEx *get_script_dispatch(IActiveScript *script)
+{
+ IDispatchEx *dispex;
+ IDispatch *disp;
+ HRESULT hres;
+
+ disp = (void*)0xdeadbeef;
+ hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
+ ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
+
+ IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
+ IDispatch_Release(disp);
+ ok(hres == S_OK, "Could not get IDispatch iface: %08x\n", hres);
+ return dispex;
+}
+
+static void test_no_script_dispatch(IActiveScript *script)
+{
+ IDispatch *disp;
+ HRESULT hres;
+
+ disp = (void*)0xdeadbeef;
+ hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
+ ok(hres == E_UNEXPECTED, "hres = %08x, expected E_UNEXPECTED\n", hres);
+ ok(!disp, "disp != NULL\n");
}
static void test_safety(IUnknown *unk)
@@ -295,10 +328,54 @@
IObjectSafety_Release(safety);
}
+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;
+}
+
+static void test_invoke_versioning(IActiveScript *script)
+{
+ VARIANT v;
+ HRESULT hres;
+
+ V_VT(&v) = VT_NULL;
+ hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
+ if(hres == E_NOTIMPL) {
+ win_skip("SCRIPTPROP_INVOKESTRING not supported\n");
+ return;
+ }
+ ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed:
%08x\n", hres);
+
+ V_VT(&v) = VT_I2;
+ V_I2(&v) = 0;
+ hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
+ ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed:
%08x\n", hres);
+
+ V_VT(&v) = VT_I4;
+ V_I4(&v) = 16;
+ hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
+ ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed:
%08x\n", hres);
+
+ V_VT(&v) = VT_I4;
+ V_I4(&v) = 2;
+ hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
+ ok(hres == S_OK, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n",
hres);
+}
+
static void test_jscript(void)
{
IActiveScriptParse *parse;
IActiveScript *script;
+ IDispatchEx *dispex;
IUnknown *unk;
ULONG ref;
HRESULT hres;
@@ -322,6 +399,7 @@
test_state(script, SCRIPTSTATE_UNINITIALIZED);
test_safety(unk);
+ test_invoke_versioning(script);
hres = IActiveScriptParse64_InitNew(parse);
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
@@ -333,7 +411,7 @@
ok(hres == E_POINTER, "SetScriptSite failed: %08x, expected E_POINTER\n",
hres);
test_state(script, SCRIPTSTATE_UNINITIALIZED);
- test_script_dispatch(script, FALSE);
+ test_no_script_dispatch(script);
SET_EXPECT(GetLCID);
SET_EXPECT(OnStateChange_INITIALIZED);
@@ -347,7 +425,8 @@
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected
E_UNEXPECTED\n", hres);
- test_script_dispatch(script, TRUE);
+ dispex = get_script_dispatch(script);
+ test_script_dispatch(dispex);
SET_EXPECT(OnStateChange_STARTED);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED);
@@ -362,7 +441,9 @@
CHECK_CALLED(OnStateChange_CLOSED);
test_state(script, SCRIPTSTATE_CLOSED);
- test_script_dispatch(script, FALSE);
+ test_no_script_dispatch(script);
+ test_script_dispatch(dispex);
+ IDispatchEx_Release(dispex);
IUnknown_Release(parse);
IActiveScript_Release(script);
@@ -430,7 +511,7 @@
CHECK_CALLED(OnStateChange_CLOSED);
test_state(script, SCRIPTSTATE_CLOSED);
- test_script_dispatch(script, FALSE);
+ test_no_script_dispatch(script);
IUnknown_Release(parse);
IActiveScript_Release(script);
Modified: trunk/rostests/winetests/jscript/jscript.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/jscript/jscript…
==============================================================================
--- trunk/rostests/winetests/jscript/jscript.rbuild [iso-8859-1] (original)
+++ trunk/rostests/winetests/jscript/jscript.rbuild [iso-8859-1] Tue Mar 2 20:52:22 2010
@@ -3,13 +3,15 @@
<group>
<module name="jscript_winetest" type="win32cui"
installbase="bin" installname="jscript_winetest.exe"
allowwarnings="true">
<include base="jscript_winetest">.</include>
- <define name="__ROS_LONG64__" />
+ <define name="__ROS_LONG64__" />
+ <file>activex.c</file>
<file>jscript.c</file>
<file>run.c</file>
<file>testlist.c</file>
<file>rsrc.rc</file>
<library>wine</library>
<library>ole32</library>
+ <library>advapi32</library>
<library>oleaut32</library>
<library>ntdll</library>
</module>
Modified: trunk/rostests/winetests/jscript/lang.js
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/jscript/lang.js…
==============================================================================
--- trunk/rostests/winetests/jscript/lang.js [iso-8859-1] (original)
+++ trunk/rostests/winetests/jscript/lang.js [iso-8859-1] Tue Mar 2 20:52:22 2010
@@ -109,8 +109,14 @@
ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
+tmp = (function() {1;})();
+ok(tmp === undefined, "tmp = " + tmp);
+tmp = eval("1;");
+ok(tmp === 1, "tmp = " + tmp);
+
var obj1 = new Object();
ok(typeof(obj1) === "object", "typeof(obj1) is not object");
+ok(obj1.constructor === Object, "unexpected obj1.constructor");
obj1.test = true;
obj1.func = function () {
ok(this === obj1, "this is not obj1");
@@ -139,6 +145,7 @@
var obj2 = new testConstr1(true);
ok(typeof(obj2) === "object", "typeof(obj2) is not object");
+ok(obj2.constructor === testConstr1, "unexpected obj2.constructor");
ok(obj2.pvar === 1, "obj2.pvar is not 1");
testConstr1.prototype.pvar = 2;
@@ -147,6 +154,21 @@
obj2.pvar = 3;
testConstr1.prototype.pvar = 1;
ok(obj2.pvar === 3, "obj2.pvar is not 3");
+
+obj1 = new Object();
+function testConstr3() {
+ return obj1;
+}
+
+obj2 = new testConstr3();
+ok(obj1 === obj2, "obj1 != obj2");
+
+function testConstr4() {
+ return 2;
+}
+
+obj2 = new testConstr3();
+ok(typeof(obj2) === "object", "typeof(obj2) = " + typeof(obj2));
var obj3 = new Object;
ok(typeof(obj3) === "object", "typeof(obj3) is not object");
@@ -189,6 +211,7 @@
var obj3 = { prop1: 1, prop2: typeof(false) };
ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
ok(obj3.prop2 === "boolean", "obj3.prop2 is not
\"boolean\"");
+ok(obj3.constructor === Object, "unexpected obj3.constructor");
{
var blockVar = 1;
@@ -326,6 +349,15 @@
ok(tmp === -3, "-3.5 | 0 !== -3");
ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
+tmp = 0 | NaN;
+ok(tmp === 0, "0 | NaN = " + tmp);
+
+tmp = 0 | Infinity;
+ok(tmp === 0, "0 | NaN = " + tmp);
+
+tmp = 0 | (-Infinity);
+ok(tmp === 0, "0 | NaN = " + tmp);
+
tmp = 10;
ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
@@ -359,6 +391,9 @@
tmp = -64 >>> 4;
ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
+
+tmp = 4 >>> NaN;
+ok(tmp === 4, "4 >>> NaN = " + tmp);
tmp = 10;
ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
@@ -390,8 +425,10 @@
tmp = new Number(1);
ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
+ok(tmp.constructor === Number, "unexpected tmp.constructor");
tmp = new String("1");
ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
+ok(tmp.constructor === String, "unexpected tmp.constructor");
ok("" + 0 === "0", "\"\" + 0 !==
\"0\"");
ok("" + 123 === "123", "\"\" + 123 !==
\"123\"");
@@ -831,6 +868,13 @@
obj = [1,2,3];
ok((1 in obj) === true, "1 is not in obj");
+obj = new Object();
+try {
+ obj.prop["test"];
+ ok(false, "expected exception");
+}catch(e) {}
+ok(!("prop" in obj), "prop in obj");
+
ok(isNaN(NaN) === true, "isNaN(NaN) !== true");
ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false");
@@ -933,6 +977,11 @@
var re = /=(\?|%3F)/g;
ok(re.source === "=(\\?|%3F)", "re.source = " + re.source);
+
+tmp = new Array();
+for(var i=0; i<2; i++)
+ tmp[i] = /b/;
+ok(tmp[0] != tmp[1], "tmp[0] == tmp [1]");
ok(createNullBSTR() === '', "createNullBSTR() !== ''");
@@ -969,4 +1018,10 @@
(function() { newValue = 1; })();
ok(newValue === 1, "newValue = " + newValue);
+obj = {undefined: 3};
+
+/* Keep this test in the end of file */
+undefined = 6;
+ok(undefined === 6, "undefined = " + undefined);
+
reportSuccess();
Modified: trunk/rostests/winetests/jscript/regexp.js
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/jscript/regexp.…
==============================================================================
--- trunk/rostests/winetests/jscript/regexp.js [iso-8859-1] (original)
+++ trunk/rostests/winetests/jscript/regexp.js [iso-8859-1] Tue Mar 2 20:52:22 2010
@@ -17,7 +17,7 @@
*/
-var m, re, b;
+var m, re, b, i, obj;
re = /a+/;
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
@@ -70,6 +70,11 @@
m = re.exec();
ok(m === null, "m is not null");
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
+
+m = /(a|b)+|(c)/.exec("aa");
+ok(m[0] === "aa", "m[0] = " + m[0]);
+ok(m[1] === "a", "m[1] = " + m[1]);
+ok(m[2] === "", "m[2] = " + m[2]);
b = re.test(" a ");
ok(b === true, "re.test(' a ') returned " + b);
@@ -91,10 +96,12 @@
b = /a*/.test();
ok(b === true, "/a*/.test() returned " + b);
-m = "abcabc".match(/ca/);
+m = "abcabc".match(re = /ca/);
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 1, "m.length is not 1");
ok(m["0"] === "ca", "m[0] is not \"ca\"");
+ok(m.constructor === Array, "unexpected m.constructor");
+ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex);
m = "abcabc".match(/ab/);
ok(typeof(m) === "object", "typeof m is not object");
@@ -160,8 +167,9 @@
m = "abcabc".match();
ok(m === null, "m is not null");
-r = "- [test] -".replace(/\[([^\[]+)\]/g, "success");
+r = "- [test] -".replace(re = /\[([^\[]+)\]/g, "success");
ok(r === "- success -", "r = " + r + " expected '- success
-'");
+ok(re.lastIndex === 8, "re.lastIndex = " + re.lastIndex);
r = "[test] [test]".replace(/\[([^\[]+)\]/g, "aa");
ok(r === "aa aa", "r = " + r + "aa aa");
@@ -280,6 +288,41 @@
ok(r[0] === "1", "r[0] = " + r[0]);
ok(r[1] === "2", "r[1] = " + r[1]);
+re = /,+/;
+r = "1,,2,".split(re);
+ok(r.length === 2, "r.length = " + r.length);
+ok(r[0] === "1", "r[0] = " + r[0]);
+ok(r[1] === "2", "r[1] = " + r[1]);
+ok(re.lastIndex === 5, "re.lastIndex = " + re.lastIndex);
+
+re = /,+/g;
+r = "1,,2,".split(re);
+ok(r.length === 2, "r.length = " + r.length);
+ok(r[0] === "1", "r[0] = " + r[0]);
+ok(r[1] === "2", "r[1] = " + r[1]);
+ok(re.lastIndex === 5, "re.lastIndex = " + re.lastIndex);
+
+r = "1 12 \t3".split(re = /\s+/).join(";");
+ok(r === "1;12;3", "r = " + r);
+ok(re.lastIndex === 6, "re.lastIndex = " + re.lastIndex);
+
+r = "123".split(re = /\s+/).join(";");
+ok(r === "123", "r = " + r);
+ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
+
+/* another standard violation */
+r = "1 12 \t3".split(re = /(\s)+/g).join(";");
+ok(r === "1;12;3", "r = " + r);
+ok(re.lastIndex === 6, "re.lastIndex = " + re.lastIndex);
+
+re = /,+/;
+re.lastIndex = 4;
+r = "1,,2,".split(re);
+ok(r.length === 2, "r.length = " + r.length);
+ok(r[0] === "1", "r[0] = " + r[0]);
+ok(r[1] === "2", "r[1] = " + r[1]);
+ok(re.lastIndex === 5, "re.lastIndex = " + re.lastIndex);
+
re = /abc[^d]/g;
ok(re.source === "abc[^d]", "re.source = '" + re.source +
"', expected 'abc[^d]'");
@@ -298,4 +341,117 @@
re = /abc/;
ok(re === RegExp(re, undefined, 1), "re !== RegExp(re, undefined, 1)");
+re = /a/g;
+ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected
0");
+
+m = re.exec(" a ");
+ok(re.lastIndex === 2, "re.lastIndex = " + re.lastIndex + " expected
2");
+ok(m.index === 1, "m.index = " + m.index + " expected 1");
+
+m = re.exec(" a ");
+ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected
0");
+ok(m === null, "m = " + m + " expected null");
+
+re.lastIndex = 2;
+m = re.exec(" a a ");
+ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex + " expected
4");
+ok(m.index === 3, "m.index = " + m.index + " expected 3");
+
+re.lastIndex = "2";
+ok(re.lastIndex === "2", "re.lastIndex = " + re.lastIndex + "
expected '2'");
+m = re.exec(" a a ");
+ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex + " expected
4");
+ok(m.index === 3, "m.index = " + m.index + " expected 3");
+
+var li = 0;
+var obj = new Object();
+obj.valueOf = function() { return li; };
+
+re.lastIndex = obj;
+ok(re.lastIndex === obj, "re.lastIndex = " + re.lastIndex + " expected
obj");
+li = 2;
+m = re.exec(" a a ");
+ok(re.lastIndex === 2, "re.lastIndex = " + re.lastIndex + " expected
2");
+ok(m.index === 1, "m.index = " + m.index + " expected 1");
+
+re.lastIndex = 3;
+re.lastIndex = "test";
+ok(re.lastIndex === "test", "re.lastIndex = " + re.lastIndex + "
expected 'test'");
+m = re.exec(" a a ");
+ok(re.lastIndex === 2 || re.lastIndex === 0, "re.lastIndex = " + re.lastIndex +
" expected 2 or 0");
+if(re.lastIndex != 0)
+ ok(m.index === 1, "m.index = " + m.index + " expected 1");
+else
+ ok(m === null, "m = " + m + " expected null");
+
+re.lastIndex = 0;
+re.lastIndex = 3.9;
+ok(re.lastIndex === 3.9, "re.lastIndex = " + re.lastIndex + " expected
3.9");
+m = re.exec(" a a ");
+ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex + " expected
4");
+ok(m.index === 3, "m.index = " + m.index + " expected 3");
+
+obj.valueOf = function() { throw 0; }
+re.lastIndex = obj;
+ok(re.lastIndex === obj, "unexpected re.lastIndex");
+m = re.exec(" a a ");
+ok(re.lastIndex === 2, "re.lastIndex = " + re.lastIndex + " expected
2");
+ok(m.index === 1, "m.index = " + m.index + " expected 1");
+
+re.lastIndex = -3;
+ok(re.lastIndex === -3, "re.lastIndex = " + re.lastIndex + " expected
-3");
+m = re.exec(" a a ");
+ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected
0");
+ok(m === null, "m = " + m + " expected null");
+
+re.lastIndex = -1;
+ok(re.lastIndex === -1, "re.lastIndex = " + re.lastIndex + " expected
-1");
+m = re.exec(" ");
+ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected
0");
+ok(m === null, "m = " + m + " expected null");
+
+re = /aa/g;
+i = 'baacd'.search(re);
+ok(i === 1, "'baacd'.search(re) = " + i);
+ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex);
+
+re.lastIndex = 2;
+i = 'baacdaa'.search(re);
+ok(i === 1, "'baacd'.search(re) = " + i);
+ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex);
+
+re = /aa/;
+i = 'baacd'.search(re);
+ok(i === 1, "'baacd'.search(re) = " + i);
+ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex);
+
+re.lastIndex = 2;
+i = 'baacdaa'.search(re);
+ok(i === 1, "'baacd'.search(re) = " + i);
+ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex);
+
+re = /d/g;
+re.lastIndex = 1;
+i = 'abc'.search(re);
+ok(i === -1, "'abc'.search(/d/g) = " + i);
+ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
+
+i = 'abcdde'.search(/[df]/);
+ok(i === 3, "'abc'.search(/[df]/) = " + i);
+
+i = 'abcdde'.search(/[df]/, "a");
+ok(i === 3, "'abc'.search(/[df]/) = " + i);
+
+i = 'abcdde'.search("[df]");
+ok(i === 3, "'abc'.search(/d*/) = " + i);
+
+obj = {
+ toString: function() { return "abc"; }
+};
+i = String.prototype.search.call(obj, "b");
+ok(i === 1, "String.prototype.seatch.apply(obj, 'b') = " + i);
+
+i = " undefined ".search();
+ok(i === null, "' undefined '.search() = " + i);
+
reportSuccess();
Modified: trunk/rostests/winetests/jscript/run.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/jscript/run.c?r…
==============================================================================
--- trunk/rostests/winetests/jscript/run.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/jscript/run.c [iso-8859-1] Tue Mar 2 20:52:22 2010
@@ -81,6 +81,7 @@
#define DISPID_GLOBAL_NULL_DISP 0x1008
#define DISPID_GLOBAL_TESTTHIS 0x1009
#define DISPID_GLOBAL_TESTTHIS2 0x100a
+#define DISPID_GLOBAL_INVOKEVERSION 0x100b
#define DISPID_TESTOBJ_PROP 0x2000
@@ -92,6 +93,7 @@
static BOOL strict_dispid_check;
static const char *test_name = "(null)";
static IDispatch *script_disp;
+static int invoke_version;
static BSTR a2bstr(const char *str)
{
@@ -110,6 +112,13 @@
CHAR buf[512];
WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
return lstrcmpA(buf, stra);
+}
+
+#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);
}
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void
**ppv)
@@ -205,13 +214,13 @@
{
if(!strcmp_wa(bstrName, "prop")) {
CHECK_EXPECT(testobj_prop_d);
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_TESTOBJ_PROP;
return S_OK;
}
if(!strcmp_wa(bstrName, "noprop")) {
CHECK_EXPECT(testobj_noprop_d);
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
return DISP_E_UNKNOWNNAME;
}
@@ -250,7 +259,7 @@
CHECK_EXPECT(testobj_delete);
ok(!strcmp_wa(bstrName, "deleteTest"), "unexpected name %s\n",
wine_dbgstr_w(bstrName));
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
return S_OK;
}
@@ -277,40 +286,40 @@
static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex,
DISPID *pid)
{
if(!strcmp_wa(bstrName, "ok")) {
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_GLOBAL_OK;
return S_OK;
}
if(!strcmp_wa(bstrName, "trace")) {
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_GLOBAL_TRACE;
return S_OK;
}
if(!strcmp_wa(bstrName, "reportSuccess")) {
CHECK_EXPECT(global_success_d);
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_GLOBAL_REPORTSUCCESS;
return S_OK;
}
if(!strcmp_wa(bstrName, "testPropGet")) {
CHECK_EXPECT(global_propget_d);
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_GLOBAL_TESTPROPGET;
return S_OK;
}
if(!strcmp_wa(bstrName, "testPropPut")) {
CHECK_EXPECT(global_propput_d);
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_GLOBAL_TESTPROPPUT;
return S_OK;
}
if(!strcmp_wa(bstrName, "getVT")) {
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_GLOBAL_GETVT;
return S_OK;
}
if(!strcmp_wa(bstrName, "testObj")) {
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_GLOBAL_TESTOBJ;
return S_OK;
}
@@ -324,19 +333,25 @@
}
if(!strcmp_wa(bstrName, "notExists")) {
CHECK_EXPECT(global_notexists_d);
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
return DISP_E_UNKNOWNNAME;
}
if(!strcmp_wa(bstrName, "testThis")) {
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_GLOBAL_TESTTHIS;
return S_OK;
}
if(!strcmp_wa(bstrName, "testThis2")) {
- ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_GLOBAL_TESTTHIS2;
+ return S_OK;
+ }
+
+ if(!strcmp_wa(bstrName, "invokeVersion")) {
+ test_grfdex(grfdex, fdexNameCaseSensitive);
+ *pid = DISPID_GLOBAL_INVOKEVERSION;
return S_OK;
}
@@ -536,6 +551,23 @@
ok(V_DISPATCH(pdp->rgvarg) == script_disp, "disp !=
script_disp\n");
return S_OK;
+
+ 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;
+
}
ok(0, "unexpected call %x\n", id);
@@ -657,19 +689,44 @@
static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl };
+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;
+}
+
static IActiveScript *create_script(void)
{
IActiveScript *script;
+ VARIANT v;
HRESULT hres;
hres = CoCreateInstance(&CLSID_JScript, NULL,
CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IActiveScript, (void**)&script);
ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
+ 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;
+ }
+
return script;
}
-static void parse_script(DWORD flags, BSTR script_str)
+static HRESULT parse_script(DWORD flags, BSTR script_str)
{
IActiveScriptParse *parser;
IActiveScript *engine;
@@ -677,14 +734,14 @@
engine = create_script();
if(!engine)
- return;
+ return S_OK;
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;
+ return hres;
}
hres = IActiveScriptParse64_InitNew(parser);
@@ -706,11 +763,12 @@
ok(script_disp != (IDispatch*)&Global, "script_disp == Global\n");
hres = IActiveScriptParse64_ParseScriptText(parser, script_str, NULL, NULL, NULL, 0,
0, 0, NULL, NULL);
- ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
IDispatch_Release(script_disp);
IActiveScript_Release(engine);
IUnknown_Release(parser);
+
+ return hres;
}
static HRESULT parse_htmlscript(BSTR script_str)
@@ -756,9 +814,13 @@
static void parse_script_af(DWORD flags, const char *src)
{
- BSTR tmp = a2bstr(src);
- parse_script(flags, tmp);
+ BSTR tmp;
+ HRESULT hres;
+
+ tmp = a2bstr(src);
+ hres = parse_script(flags, tmp);
SysFreeString(tmp);
+ ok(hres == S_OK, "parse_script failed: %08x\n", hres);
}
static void parse_script_a(const char *src)
@@ -816,14 +878,17 @@
static void run_from_file(const char *filename)
{
- BSTR script_str = get_script_from_file(filename);
+ BSTR script_str;
+ HRESULT hres;
+
+ script_str = get_script_from_file(filename);
+ if(!script_str)
+ return;
strict_dispid_check = FALSE;
-
- if(script_str)
- parse_script(SCRIPTITEM_GLOBALMEMBERS, script_str);
-
+ hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, script_str);
SysFreeString(script_str);
+ ok(hres == S_OK, "parse_script failed: %08x\n", hres);
}
static void run_from_res(const char *name)
@@ -832,6 +897,7 @@
DWORD size, len;
BSTR str;
HRSRC src;
+ HRESULT hres;
strict_dispid_check = FALSE;
test_name = name;
@@ -848,10 +914,11 @@
SET_EXPECT(global_success_d);
SET_EXPECT(global_success_i);
- parse_script(SCRIPTITEM_GLOBALMEMBERS, str);
+ hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, str);
CHECK_CALLED(global_success_d);
CHECK_CALLED(global_success_i);
+ ok(hres == S_OK, "parse_script failed: %08x\n", hres);
SysFreeString(str);
}
@@ -911,6 +978,17 @@
static void run_tests(void)
{
HRESULT hres;
+
+ if(invoke_version) {
+ IActiveScript *script;
+
+ script = create_script();
+ if(!script) {
+ win_skip("Could not create script\n");
+ return;
+ }
+ IActiveScript_Release(script);
+ }
strict_dispid_check = TRUE;
@@ -1010,6 +1088,18 @@
ok(hres != S_OK, "ParseScriptText have not failed\n");
}
+static BOOL check_jscript(void)
+{
+ BSTR str;
+ HRESULT hres;
+
+ str = a2bstr("if(!('localeCompare' in String.prototype)) throw
1;");
+ hres = parse_script(0, str);
+ SysFreeString(str);
+
+ return hres == S_OK;
+}
+
START_TEST(run)
{
int argc;
@@ -1019,10 +1109,19 @@
CoInitialize(NULL);
- if(argc > 2)
+ if(!check_jscript()) {
+ win_skip("Broken engine, probably too old\n");
+ }else if(argc > 2) {
run_from_file(argv[2]);
- else
+ }else {
+ trace("invoke version 0\n");
+ invoke_version = 0;
run_tests();
+ trace("invoke version 2\n");
+ invoke_version = 2;
+ run_tests();
+ }
+
CoUninitialize();
}
Modified: trunk/rostests/winetests/jscript/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/jscript/testlis…
==============================================================================
--- trunk/rostests/winetests/jscript/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/jscript/testlist.c [iso-8859-1] Tue Mar 2 20:52:22 2010
@@ -6,11 +6,13 @@
#define STANDALONE
#include "wine/test.h"
+extern void func_activex(void);
extern void func_jscript(void);
extern void func_run(void);
const struct test winetest_testlist[] =
{
+ { "activex", func_activex },
{ "jscript", func_jscript },
{ "run", func_run },
{ 0, 0 }