jscript/tests: Use wide char string literals instead of a2bstr.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
363301a897
commit
0c0c5607f8
|
@ -204,18 +204,6 @@ static BOOL is_lang_english(void)
|
||||||
return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
|
return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
static int strcmp_wa(LPCWSTR strw, const char *stra)
|
||||||
{
|
{
|
||||||
CHAR buf[512];
|
CHAR buf[512];
|
||||||
|
@ -1140,28 +1128,28 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
|
||||||
V_VT(pvarRes) = VT_BSTR;
|
V_VT(pvarRes) = VT_BSTR;
|
||||||
switch(V_VT(pdp->rgvarg)) {
|
switch(V_VT(pdp->rgvarg)) {
|
||||||
case VT_EMPTY:
|
case VT_EMPTY:
|
||||||
V_BSTR(pvarRes) = a2bstr("VT_EMPTY");
|
V_BSTR(pvarRes) = SysAllocString(L"VT_EMPTY");
|
||||||
break;
|
break;
|
||||||
case VT_NULL:
|
case VT_NULL:
|
||||||
V_BSTR(pvarRes) = a2bstr("VT_NULL");
|
V_BSTR(pvarRes) = SysAllocString(L"VT_NULL");
|
||||||
break;
|
break;
|
||||||
case VT_I4:
|
case VT_I4:
|
||||||
V_BSTR(pvarRes) = a2bstr("VT_I4");
|
V_BSTR(pvarRes) = SysAllocString(L"VT_I4");
|
||||||
break;
|
break;
|
||||||
case VT_R8:
|
case VT_R8:
|
||||||
V_BSTR(pvarRes) = a2bstr("VT_R8");
|
V_BSTR(pvarRes) = SysAllocString(L"VT_R8");
|
||||||
break;
|
break;
|
||||||
case VT_BSTR:
|
case VT_BSTR:
|
||||||
V_BSTR(pvarRes) = a2bstr("VT_BSTR");
|
V_BSTR(pvarRes) = SysAllocString(L"VT_BSTR");
|
||||||
break;
|
break;
|
||||||
case VT_DISPATCH:
|
case VT_DISPATCH:
|
||||||
V_BSTR(pvarRes) = a2bstr("VT_DISPATCH");
|
V_BSTR(pvarRes) = SysAllocString(L"VT_DISPATCH");
|
||||||
break;
|
break;
|
||||||
case VT_BOOL:
|
case VT_BOOL:
|
||||||
V_BSTR(pvarRes) = a2bstr("VT_BOOL");
|
V_BSTR(pvarRes) = SysAllocString(L"VT_BOOL");
|
||||||
break;
|
break;
|
||||||
case VT_ARRAY|VT_VARIANT:
|
case VT_ARRAY|VT_VARIANT:
|
||||||
V_BSTR(pvarRes) = a2bstr("VT_ARRAY|VT_VARIANT");
|
V_BSTR(pvarRes) = SysAllocString(L"VT_ARRAY|VT_VARIANT");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ok(0, "unknown vt %d\n", V_VT(pdp->rgvarg));
|
ok(0, "unknown vt %d\n", V_VT(pdp->rgvarg));
|
||||||
|
@ -1466,7 +1454,7 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
|
||||||
hres = IDispatch_QueryInterface(script_disp, &IID_IDispatchEx, (void**)&dispex);
|
hres = IDispatch_QueryInterface(script_disp, &IID_IDispatchEx, (void**)&dispex);
|
||||||
ok(hres == S_OK, "hres = %x\n", hres);
|
ok(hres == S_OK, "hres = %x\n", hres);
|
||||||
|
|
||||||
str = a2bstr("Object");
|
str = SysAllocString(L"Object");
|
||||||
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
|
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
ok(hres == S_OK, "hres = %x\n", hres);
|
ok(hres == S_OK, "hres = %x\n", hres);
|
||||||
|
@ -1602,7 +1590,7 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
|
||||||
params.cNamedArgs = 0;
|
params.cNamedArgs = 0;
|
||||||
V_VT(&arg) = VT_BSTR;
|
V_VT(&arg) = VT_BSTR;
|
||||||
|
|
||||||
V_BSTR(&arg) = a2bstr("var x = 5; v");
|
V_BSTR(&arg) = SysAllocString(L"var x = 5; v");
|
||||||
V_VT(&res) = VT_ERROR;
|
V_VT(&res) = VT_ERROR;
|
||||||
hres = IDispatchEx_InvokeEx(eval_func, DISPID_VALUE, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
|
hres = IDispatchEx_InvokeEx(eval_func, DISPID_VALUE, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
|
||||||
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
||||||
|
@ -1862,14 +1850,13 @@ static HRESULT parse_script(DWORD flags, const WCHAR *script_str)
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT invoke_procedure(const char *argsa, const char *sourcea, DISPPARAMS *dp)
|
static HRESULT invoke_procedure(const WCHAR *args, const WCHAR *source, DISPPARAMS *dp)
|
||||||
{
|
{
|
||||||
IActiveScriptParseProcedure2 *parse_proc;
|
IActiveScriptParseProcedure2 *parse_proc;
|
||||||
IActiveScriptParse *parser;
|
IActiveScriptParse *parser;
|
||||||
IActiveScript *engine;
|
IActiveScript *engine;
|
||||||
IDispatchEx *dispex;
|
IDispatchEx *dispex;
|
||||||
EXCEPINFO ei = {0};
|
EXCEPINFO ei = {0};
|
||||||
BSTR source, args;
|
|
||||||
IDispatch *disp;
|
IDispatch *disp;
|
||||||
VARIANT res;
|
VARIANT res;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
@ -1893,13 +1880,9 @@ static HRESULT invoke_procedure(const char *argsa, const char *sourcea, DISPPARA
|
||||||
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParseProcedure2, (void**)&parse_proc);
|
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParseProcedure2, (void**)&parse_proc);
|
||||||
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
|
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,
|
hres = IActiveScriptParseProcedure2_ParseProcedureText(parse_proc, source, args, emptyW, NULL, NULL, NULL, 0, 0,
|
||||||
SCRIPTPROC_HOSTMANAGESSOURCE|SCRIPTPROC_IMPLICIT_THIS|SCRIPTPROC_IMPLICIT_PARENTS, &disp);
|
SCRIPTPROC_HOSTMANAGESSOURCE|SCRIPTPROC_IMPLICIT_THIS|SCRIPTPROC_IMPLICIT_PARENTS, &disp);
|
||||||
ok(hres == S_OK, "ParseProcedureText failed: %08x\n", hres);
|
ok(hres == S_OK, "ParseProcedureText failed: %08x\n", hres);
|
||||||
SysFreeString(source);
|
|
||||||
SysFreeString(args);
|
|
||||||
|
|
||||||
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
|
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
|
||||||
ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
|
ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
|
||||||
|
@ -1923,7 +1906,6 @@ static HRESULT parse_htmlscript(const WCHAR *script_str)
|
||||||
IActiveScriptParse *parser;
|
IActiveScriptParse *parser;
|
||||||
IActiveScript *engine;
|
IActiveScript *engine;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
BSTR tmp = a2bstr("</SCRIPT>");
|
|
||||||
|
|
||||||
engine = create_script();
|
engine = create_script();
|
||||||
if(!engine)
|
if(!engine)
|
||||||
|
@ -1950,12 +1932,10 @@ static HRESULT parse_htmlscript(const WCHAR *script_str)
|
||||||
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
||||||
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
||||||
|
|
||||||
hres = IActiveScriptParse_ParseScriptText(parser, script_str, NULL, NULL, tmp, 0, 0, 0, NULL, NULL);
|
hres = IActiveScriptParse_ParseScriptText(parser, script_str, NULL, NULL, L"</SCRIPT>", 0, 0, 0, NULL, NULL);
|
||||||
|
|
||||||
IActiveScript_Release(engine);
|
IActiveScript_Release(engine);
|
||||||
IActiveScriptParse_Release(parser);
|
IActiveScriptParse_Release(parser);
|
||||||
SysFreeString(tmp);
|
|
||||||
|
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2281,8 +2261,8 @@ static void test_start(void)
|
||||||
hres = IActiveScript_AddNamedItem(engine, testW, SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
hres = IActiveScript_AddNamedItem(engine, testW, SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
||||||
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
||||||
|
|
||||||
str = a2bstr("ok(getScriptState() === 5, \"getScriptState = \" + getScriptState());\n"
|
str = SysAllocString(L"ok(getScriptState() === 5, \"getScriptState = \" + getScriptState());\n"
|
||||||
"reportSuccess();");
|
L"reportSuccess();");
|
||||||
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
||||||
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
@ -2322,8 +2302,8 @@ static void test_automagic(void)
|
||||||
hres = IActiveScript_AddNamedItem(engine, testW, SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
hres = IActiveScript_AddNamedItem(engine, testW, SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
|
||||||
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
||||||
|
|
||||||
str = a2bstr("function bindEventHandler::eventName() {}\n"
|
str = SysAllocString(L"function bindEventHandler::eventName() {}\n"
|
||||||
"reportSuccess();");
|
L"reportSuccess();");
|
||||||
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
||||||
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
@ -2342,11 +2322,10 @@ static void test_automagic(void)
|
||||||
script_engine = NULL;
|
script_engine = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT parse_script_expr(const char *expr, VARIANT *res, IActiveScript **engine_ret)
|
static HRESULT parse_script_expr(const WCHAR *expr, VARIANT *res, IActiveScript **engine_ret)
|
||||||
{
|
{
|
||||||
IActiveScriptParse *parser;
|
IActiveScriptParse *parser;
|
||||||
IActiveScript *engine;
|
IActiveScript *engine;
|
||||||
BSTR str;
|
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
engine = create_script();
|
engine = create_script();
|
||||||
|
@ -2371,10 +2350,7 @@ static HRESULT parse_script_expr(const char *expr, VARIANT *res, IActiveScript *
|
||||||
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
|
||||||
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
||||||
|
|
||||||
str = a2bstr(expr);
|
hres = IActiveScriptParse_ParseScriptText(parser, expr, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, res, NULL);
|
||||||
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, res, NULL);
|
|
||||||
SysFreeString(str);
|
|
||||||
|
|
||||||
IActiveScriptParse_Release(parser);
|
IActiveScriptParse_Release(parser);
|
||||||
|
|
||||||
if(engine_ret)
|
if(engine_ret)
|
||||||
|
@ -2413,7 +2389,7 @@ static void test_retval(void)
|
||||||
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
|
||||||
CHECK_CALLED(GetItemInfo_testVal);
|
CHECK_CALLED(GetItemInfo_testVal);
|
||||||
|
|
||||||
str = a2bstr("reportSuccess(), true");
|
str = SysAllocString(L"reportSuccess(), true");
|
||||||
V_VT(&res) = VT_NULL;
|
V_VT(&res) = VT_NULL;
|
||||||
SET_EXPECT(global_success_d);
|
SET_EXPECT(global_success_d);
|
||||||
SET_EXPECT(global_success_i);
|
SET_EXPECT(global_success_i);
|
||||||
|
@ -2443,7 +2419,7 @@ static void test_default_value(void)
|
||||||
VARIANT v;
|
VARIANT v;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
hres = parse_script_expr("new Date()", &v, NULL);
|
hres = parse_script_expr(L"new Date()", &v, NULL);
|
||||||
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
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));
|
ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
|
||||||
disp = V_DISPATCH(&v);
|
disp = V_DISPATCH(&v);
|
||||||
|
@ -2467,38 +2443,38 @@ static void test_script_exprs(void)
|
||||||
|
|
||||||
testing_expr = TRUE;
|
testing_expr = TRUE;
|
||||||
|
|
||||||
hres = parse_script_expr("true", &v, NULL);
|
hres = parse_script_expr(L"true", &v, NULL);
|
||||||
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
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_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));
|
ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
|
||||||
|
|
||||||
hres = parse_script_expr("false, true", &v, NULL);
|
hres = parse_script_expr(L"false, true", &v, NULL);
|
||||||
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
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_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));
|
ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
|
||||||
|
|
||||||
SET_EXPECT(global_success_d);
|
SET_EXPECT(global_success_d);
|
||||||
SET_EXPECT(global_success_i);
|
SET_EXPECT(global_success_i);
|
||||||
hres = parse_script_expr("reportSuccess(); true", &v, NULL);
|
hres = parse_script_expr(L"reportSuccess(); true", &v, NULL);
|
||||||
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
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_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));
|
ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
|
||||||
CHECK_CALLED(global_success_d);
|
CHECK_CALLED(global_success_d);
|
||||||
CHECK_CALLED(global_success_i);
|
CHECK_CALLED(global_success_i);
|
||||||
|
|
||||||
hres = parse_script_expr("if(false) true", &v, NULL);
|
hres = parse_script_expr(L"if(false) true", &v, NULL);
|
||||||
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
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));
|
ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
|
||||||
|
|
||||||
hres = parse_script_expr("return testPropGet", &v, NULL);
|
hres = parse_script_expr(L"return testPropGet", &v, NULL);
|
||||||
ok(hres == 0x800a03fa, "parse_script_expr failed: %08x\n", hres);
|
ok(hres == 0x800a03fa, "parse_script_expr failed: %08x\n", hres);
|
||||||
|
|
||||||
hres = parse_script_expr("reportSuccess(); return true", &v, NULL);
|
hres = parse_script_expr(L"reportSuccess(); return true", &v, NULL);
|
||||||
ok(hres == 0x800a03fa, "parse_script_expr failed: %08x\n", hres);
|
ok(hres == 0x800a03fa, "parse_script_expr failed: %08x\n", hres);
|
||||||
|
|
||||||
SET_EXPECT(global_success_d);
|
SET_EXPECT(global_success_d);
|
||||||
SET_EXPECT(global_success_i);
|
SET_EXPECT(global_success_i);
|
||||||
hres = parse_script_expr("reportSuccess(); true", NULL, NULL);
|
hres = parse_script_expr(L"reportSuccess(); true", NULL, NULL);
|
||||||
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
||||||
CHECK_CALLED(global_success_d);
|
CHECK_CALLED(global_success_d);
|
||||||
CHECK_CALLED(global_success_i);
|
CHECK_CALLED(global_success_i);
|
||||||
|
@ -2519,7 +2495,7 @@ static void test_invokeex(void)
|
||||||
BSTR str;
|
BSTR str;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
hres = parse_script_expr("var o = {func: function() {return 3;}, prop: 6}; o", &v, &script);
|
hres = parse_script_expr(L"var o = {func: function() {return 3;}, prop: 6}; o", &v, &script);
|
||||||
ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
|
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));
|
ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
|
||||||
|
|
||||||
|
@ -2527,12 +2503,12 @@ static void test_invokeex(void)
|
||||||
ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
|
ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
|
||||||
VariantClear(&v);
|
VariantClear(&v);
|
||||||
|
|
||||||
str = a2bstr("func");
|
str = SysAllocString(L"func");
|
||||||
hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
|
hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
||||||
|
|
||||||
str = a2bstr("prop");
|
str = SysAllocString(L"prop");
|
||||||
hres = IDispatchEx_GetDispID(dispex, str, 0, &prop_id);
|
hres = IDispatchEx_GetDispID(dispex, str, 0, &prop_id);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
||||||
|
@ -2550,7 +2526,7 @@ static void test_invokeex(void)
|
||||||
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
|
||||||
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
|
||||||
|
|
||||||
str = a2bstr("func");
|
str = SysAllocString(L"func");
|
||||||
hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
|
hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
|
||||||
|
@ -2607,7 +2583,7 @@ static void test_eval(void)
|
||||||
ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
|
ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
|
||||||
IDispatch_Release(script_disp);
|
IDispatch_Release(script_disp);
|
||||||
|
|
||||||
str = a2bstr("eval");
|
str = SysAllocString(L"eval");
|
||||||
hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id);
|
hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id);
|
||||||
ok(hres == S_OK, "Could not get eval dispid: %08x\n", hres);
|
ok(hres == S_OK, "Could not get eval dispid: %08x\n", hres);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
@ -2618,14 +2594,14 @@ static void test_eval(void)
|
||||||
params.cNamedArgs = 0;
|
params.cNamedArgs = 0;
|
||||||
V_VT(&arg) = VT_BSTR;
|
V_VT(&arg) = VT_BSTR;
|
||||||
|
|
||||||
V_BSTR(&arg) = a2bstr("var v = 1;");
|
V_BSTR(&arg) = SysAllocString(L"var v = 1;");
|
||||||
V_VT(&res) = VT_ERROR;
|
V_VT(&res) = VT_ERROR;
|
||||||
hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
|
hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
|
||||||
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
||||||
ok(V_VT(&res) == VT_EMPTY, "eval returned type %u\n", V_VT(&res));
|
ok(V_VT(&res) == VT_EMPTY, "eval returned type %u\n", V_VT(&res));
|
||||||
SysFreeString(V_BSTR(&arg));
|
SysFreeString(V_BSTR(&arg));
|
||||||
|
|
||||||
V_BSTR(&arg) = a2bstr("v");
|
V_BSTR(&arg) = SysAllocString(L"v");
|
||||||
V_VT(&res) = VT_ERROR;
|
V_VT(&res) = VT_ERROR;
|
||||||
hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
|
hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
|
||||||
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
|
||||||
|
@ -2633,7 +2609,7 @@ static void test_eval(void)
|
||||||
ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res));
|
ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res));
|
||||||
SysFreeString(V_BSTR(&arg));
|
SysFreeString(V_BSTR(&arg));
|
||||||
|
|
||||||
str = a2bstr("v");
|
str = SysAllocString(L"v");
|
||||||
hres = IDispatchEx_GetDispID(script_dispex, str, 0, &v_id);
|
hres = IDispatchEx_GetDispID(script_dispex, str, 0, &v_id);
|
||||||
ok(hres == S_OK, "Could not get v dispid: %08x\n", hres);
|
ok(hres == S_OK, "Could not get v dispid: %08x\n", hres);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
@ -2647,17 +2623,17 @@ static void test_eval(void)
|
||||||
ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res));
|
ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res));
|
||||||
|
|
||||||
SET_EXPECT(global_calleval_i);
|
SET_EXPECT(global_calleval_i);
|
||||||
str = a2bstr("(function(){"
|
hres = IActiveScriptParse_ParseScriptText(parser,
|
||||||
" var v = 2;"
|
L"(function(){"
|
||||||
" callEval(eval);"
|
L" var v = 2;"
|
||||||
" ok(x === 5, 'x = ' + x);"
|
L" callEval(eval);"
|
||||||
"})();");
|
L" ok(x === 5, 'x = ' + x);"
|
||||||
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
L"})();",
|
||||||
|
NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
||||||
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
||||||
SysFreeString(str);
|
|
||||||
CHECK_CALLED(global_calleval_i);
|
CHECK_CALLED(global_calleval_i);
|
||||||
|
|
||||||
str = a2bstr("x");
|
str = SysAllocString(L"x");
|
||||||
hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id);
|
hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id);
|
||||||
ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(x) returned %08x\n", hres);
|
ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(x) returned %08x\n", hres);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
@ -3136,22 +3112,22 @@ static void test_parse_proc(void)
|
||||||
DISPPARAMS dp = {args};
|
DISPPARAMS dp = {args};
|
||||||
|
|
||||||
dp.cArgs = 0;
|
dp.cArgs = 0;
|
||||||
invoke_procedure(NULL, "return true;", &dp);
|
invoke_procedure(NULL, L"return true;", &dp);
|
||||||
|
|
||||||
dp.cArgs = 1;
|
dp.cArgs = 1;
|
||||||
V_VT(args) = VT_EMPTY;
|
V_VT(args) = VT_EMPTY;
|
||||||
invoke_procedure(NULL, "return arguments.length == 1;", &dp);
|
invoke_procedure(NULL, L"return arguments.length == 1;", &dp);
|
||||||
|
|
||||||
V_VT(args) = VT_BOOL;
|
V_VT(args) = VT_BOOL;
|
||||||
V_BOOL(args) = VARIANT_TRUE;
|
V_BOOL(args) = VARIANT_TRUE;
|
||||||
invoke_procedure(" x ", "return x;", &dp);
|
invoke_procedure(L" x ", L"return x;", &dp);
|
||||||
|
|
||||||
dp.cArgs = 2;
|
dp.cArgs = 2;
|
||||||
V_VT(args) = VT_I4;
|
V_VT(args) = VT_I4;
|
||||||
V_I4(args) = 2;
|
V_I4(args) = 2;
|
||||||
V_VT(args+1) = VT_I4;
|
V_VT(args+1) = VT_I4;
|
||||||
V_I4(args+1) = 1;
|
V_I4(args+1) = 1;
|
||||||
invoke_procedure(" _x1 , y_2", "return _x1 === 1 && y_2 === 2;", &dp);
|
invoke_procedure(L" _x1 , y_2", L"return _x1 === 1 && y_2 === 2;", &dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_encoded_tests(void)
|
static void run_encoded_tests(void)
|
||||||
|
@ -3189,31 +3165,31 @@ static void run_encoded_tests(void)
|
||||||
CHECK_CALLED(global_success_i);
|
CHECK_CALLED(global_success_i);
|
||||||
|
|
||||||
/* v */
|
/* v */
|
||||||
src = a2bstr("#@~^EAA*AA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
|
src = SysAllocString(L"#@~^EAA*AA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
|
||||||
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
||||||
SysFreeString(src);
|
SysFreeString(src);
|
||||||
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
||||||
|
|
||||||
/* vv */
|
/* vv */
|
||||||
src = a2bstr("#@~^EAAAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
|
src = SysAllocString(L"#@~^EAAAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
|
||||||
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
||||||
SysFreeString(src);
|
SysFreeString(src);
|
||||||
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
||||||
|
|
||||||
/* v */
|
/* v */
|
||||||
src = a2bstr("#@~^EAAAAA^=.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
|
src = SysAllocString(L"#@~^EAAAAA^=.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
|
||||||
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
||||||
SysFreeString(src);
|
SysFreeString(src);
|
||||||
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
||||||
|
|
||||||
/* v */
|
/* v */
|
||||||
src = a2bstr("#@~^EAAAAA==.\x7fwGMYUEm1ekd`*iAQYAAA==^#~@");
|
src = SysAllocString(L"#@~^EAAAAA==.\x7fwGMYUEm1ekd`*iAQYAAA==^#~@");
|
||||||
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
||||||
SysFreeString(src);
|
SysFreeString(src);
|
||||||
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
||||||
|
|
||||||
/* vv */
|
/* vv */
|
||||||
src = a2bstr("#@~^EAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^~#@");
|
src = SysAllocString(L"#@~^EAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^~#@");
|
||||||
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
||||||
SysFreeString(src);
|
SysFreeString(src);
|
||||||
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
|
||||||
|
@ -3277,7 +3253,6 @@ static void run_benchmarks(void)
|
||||||
static BOOL check_jscript(void)
|
static BOOL check_jscript(void)
|
||||||
{
|
{
|
||||||
IActiveScriptProperty *script_prop;
|
IActiveScriptProperty *script_prop;
|
||||||
BSTR str;
|
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
||||||
|
@ -3286,11 +3261,7 @@ static BOOL check_jscript(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
IActiveScriptProperty_Release(script_prop);
|
IActiveScriptProperty_Release(script_prop);
|
||||||
|
|
||||||
str = a2bstr("if(!('localeCompare' in String.prototype)) throw 1;");
|
return parse_script(0, L"if(!('localeCompare' in String.prototype)) throw 1;") == S_OK;
|
||||||
hres = parse_script(0, str);
|
|
||||||
SysFreeString(str);
|
|
||||||
|
|
||||||
return hres == S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(run)
|
START_TEST(run)
|
||||||
|
|
Loading…
Reference in New Issue