mirror of
https://github.com/reactos/reactos.git
synced 2025-01-02 20:43:18 +00:00
[JSCRIPT_WINETEST] Sync with Wine Staging 1.7.47. CORE-9924
svn path=/trunk/; revision=68447
This commit is contained in:
parent
b76ad047da
commit
e7f5265814
2 changed files with 185 additions and 0 deletions
|
@ -2013,6 +2013,8 @@ ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
|
|||
"Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
|
||||
ok(Date.parse("71 11:32AM Dec 12 UTC BC ") === -64346358480000, "Date.parse(\"71 11:32AM Dec 12 UTC BC \") = " + Date.parse("71 11:32AM Dec 12 UTC BC "));
|
||||
ok(Date.parse("23/71/2000 11::32::UTC") === 1010662320000, "Date.parse(\"23/71/2000 11::32::UTC\") = " + Date.parse("23/71/2000 11::32::UTC"));
|
||||
ok(Date.parse("1970/01/01") === Date.parse("01/01/1970"), "Date.parse(\"1970/01/01\") = " + Date.parse("1970/01/01"));
|
||||
ok(Date.parse("71/12/14") === Date.parse("12/14/1971"), "Date.parse(\"71/12/14\") = " + Date.parse("71/12/14"));
|
||||
|
||||
ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
|
||||
ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
|
||||
|
|
|
@ -117,6 +117,7 @@ DEFINE_EXPECT(ActiveScriptSite_OnScriptError);
|
|||
DEFINE_EXPECT(invoke_func);
|
||||
DEFINE_EXPECT(DeleteMemberByDispID);
|
||||
DEFINE_EXPECT(DeleteMemberByDispID_false);
|
||||
DEFINE_EXPECT(BindHandler);
|
||||
|
||||
#define DISPID_GLOBAL_TESTPROPGET 0x1000
|
||||
#define DISPID_GLOBAL_TESTPROPPUT 0x1001
|
||||
|
@ -147,6 +148,7 @@ DEFINE_EXPECT(DeleteMemberByDispID_false);
|
|||
#define DISPID_GLOBAL_DISPEXFUNC 0x101a
|
||||
#define DISPID_GLOBAL_TESTPROPPUTREF 0x101b
|
||||
#define DISPID_GLOBAL_GETSCRIPTSTATE 0x101c
|
||||
#define DISPID_GLOBAL_BINDEVENTHANDLER 0x101d
|
||||
|
||||
#define DISPID_GLOBAL_TESTPROPDELETE 0x2000
|
||||
#define DISPID_GLOBAL_TESTNOPROPDELETE 0x2001
|
||||
|
@ -280,6 +282,13 @@ static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DW
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
|
||||
{
|
||||
ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
|
||||
|
@ -590,6 +599,75 @@ static IDispatchExVtbl pureDispVtbl = {
|
|||
|
||||
static IDispatchEx pureDisp = { &pureDispVtbl };
|
||||
|
||||
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 };
|
||||
|
||||
static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
|
||||
{
|
||||
if(!strcmp_wa(bstrName, "ok")) {
|
||||
|
@ -770,6 +848,11 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
if(!strcmp_wa(bstrName, "bindEventHandler")) {
|
||||
*pid = DISPID_GLOBAL_BINDEVENTHANDLER;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if(strict_dispid_check && strcmp_wa(bstrName, "t"))
|
||||
ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName));
|
||||
return DISP_E_UNKNOWNNAME;
|
||||
|
@ -1134,6 +1217,11 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
case DISPID_GLOBAL_BINDEVENTHANDLER:
|
||||
V_VT(pvarRes) = VT_DISPATCH;
|
||||
V_DISPATCH(pvarRes) = (IDispatch*)&bindEventHandlerDisp;
|
||||
return S_OK;
|
||||
|
||||
case DISPID_GLOBAL_PROPARGPUT:
|
||||
CHECK_EXPECT(global_propargput_i);
|
||||
ok(wFlags == INVOKE_PROPERTYPUT, "wFlags = %x\n", wFlags);
|
||||
|
@ -1981,6 +2069,49 @@ static void test_start(void)
|
|||
script_engine = NULL;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static HRESULT parse_script_expr(const char *expr, VARIANT *res, IActiveScript **engine_ret)
|
||||
{
|
||||
IActiveScriptParse *parser;
|
||||
|
@ -2023,6 +2154,56 @@ static HRESULT parse_script_expr(const char *expr, VARIANT *res, IActiveScript *
|
|||
return hres;
|
||||
}
|
||||
|
||||
static void test_retval(void)
|
||||
{
|
||||
BSTR str = a2bstr("reportSuccess(), true");
|
||||
IActiveScriptParse *parser;
|
||||
IActiveScript *engine;
|
||||
SCRIPTSTATE state;
|
||||
VARIANT res;
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void test_default_value(void)
|
||||
{
|
||||
DISPPARAMS dp = {0};
|
||||
|
@ -2091,6 +2272,7 @@ static void test_script_exprs(void)
|
|||
CHECK_CALLED(global_success_i);
|
||||
|
||||
test_default_value();
|
||||
test_retval();
|
||||
|
||||
testing_expr = FALSE;
|
||||
}
|
||||
|
@ -2458,6 +2640,7 @@ static BOOL run_tests(void)
|
|||
test_isvisible(FALSE);
|
||||
test_isvisible(TRUE);
|
||||
test_start();
|
||||
test_automagic();
|
||||
|
||||
parse_script_af(0, "test.testThis2(this);");
|
||||
parse_script_af(0, "(function () { test.testThis2(this); })();");
|
||||
|
|
Loading…
Reference in a new issue