https://git.reactos.org/?p=reactos.git;a=commitdiff;h=021b5c1f4daa93c06b0a9…
commit 021b5c1f4daa93c06b0a9f212a891b1e01b82431
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Sat Nov 2 18:38:32 2019 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sat Nov 2 18:38:32 2019 +0100
[JSCRIPT_WINETEST] Sync with Wine Staging 4.18. CORE-16441
---
modules/rostests/winetests/jscript/api.js | 71 ++++-
modules/rostests/winetests/jscript/caller.c | 3 +
modules/rostests/winetests/jscript/lang.js | 5 +-
modules/rostests/winetests/jscript/run.c | 406 +++++++++++++++++++++++++++-
4 files changed, 476 insertions(+), 9 deletions(-)
diff --git a/modules/rostests/winetests/jscript/api.js
b/modules/rostests/winetests/jscript/api.js
index ff6a6b781cf..d62a6434710 100644
--- a/modules/rostests/winetests/jscript/api.js
+++ b/modules/rostests/winetests/jscript/api.js
@@ -58,6 +58,8 @@ testNoEnumerables("Function");
testNoEnumerables("Function.prototype");
testNoEnumerables("testNoEnumerates");
testNoEnumerables("VBArray");
+testNoEnumerables("new Enumerator()");
+testNoEnumerables("Enumerator()");
ok(Object.propertyIsEnumerable("prototype") === false, "Object.prototype
is enumerable");
ok(Math.propertyIsEnumerable("E") === false, "Math.E is
enumerable");
@@ -154,6 +156,12 @@ i = parseInt("1", 37);
ok(isNaN(i), "parseInt('1', 37) = " + i);
i = parseInt("1", 36);
ok(i === 1, "parseInt('1', 36) = " + i);
+i = parseInt("0x1f", 16);
+ok(i === 31, "parseInt('0xf', 16) = " + i);
+i = parseInt("0x", 16);
+ok(isNaN(i), "parseInt('0x', 16) = " + i);
+i = parseInt("0x1f", 17);
+ok(i === 0, "parseInt('0xf', 16) = " + i);
tmp = encodeURI("abc");
ok(tmp === "abc", "encodeURI('abc') = " + tmp);
@@ -341,6 +349,8 @@ ok(tmp === "[object Object]", "toString.call(this) =
" + tmp);
ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
tmp = Object.prototype.toString.call(new VBArray(createArray()));
ok(tmp === "[object Object]", "toString.call(new VBArray()) = " +
tmp);
+(tmp = new Enumerator()).f = Object.prototype.toString;
+ok(tmp.f() === "[object Object]", "tmp.f() = " + tmp.f());
function TSTestConstr() {}
TSTestConstr.prototype = { toString: function() { return "test"; } };
@@ -640,6 +650,43 @@ ok(typeof(r) === "object", "typeof(r) = " +
typeof(r));
ok(r.length === 1, "r.length = " + r.length);
ok(r[0] === "", "r[0] = " + r[0]);
+(function() {
+ function test(string, separator, result) {
+ var r = string.split(separator);
+ ok(r == result, "\"" + string + "\".split(" +
separator + ") returned " + r + " expected " + result);
+ }
+
+ test("test", /^|\s+/, "test");
+ test("test", /$|\s+/, "test");
+ test("test", /^|./, "t");
+ test("test", /.*/, "");
+ test("test", /x*/, "t,e,s,t");
+ test("test", /$|x*/, "t,e,s,t");
+ test("test", /^|x*/, "t,e,s,t");
+ test("test", /t*/, "e,s");
+ test("xaabaax", /a*|b*/, "x,b,x");
+ test("xaabaax", /a+|b+/, "x,x");
+ test("xaabaax", /a+|b*/, "x,x");
+ test("xaaxbaax", /b+|a+/, "x,x,x");
+ test("test", /^|t/, "tes");
+ test("test", /^|t/, "tes");
+ test("a,,b", /,/, "a,b");
+ test("ab", /a*/, "b");
+ test("aab", "a", ",,b");
+ test("a", "a", ",");
+
+ function test_length(string, separator, len) {
+ var r = string.split(separator);
+ ok(r.length === len, "\"" + string + "\".split(" +
separator + ").length = "
+ + r.length + " expected " + len);
+ }
+
+ test_length("", /a*/, 0);
+ test_length("", /a+/, 1);
+ test_length("", "", 0);
+ test_length("", "x", 1);
+})();
+
tmp = "abcd".indexOf("bc",0);
ok(tmp === 1, "indexOf = " + tmp);
tmp = "abcd".indexOf("bc",1);
@@ -1870,11 +1917,11 @@ ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
s = JSON.stringify(testObj);
ok(s === undefined || s === "undefined" /* broken on some old versions */,
- "stringify(testObj) returned " + s + " expected undfined");
+ "stringify(testObj) returned " + s + " expected undefined");
s = JSON.stringify(undefined);
ok(s === undefined || s === "undefined" /* broken on some old versions */,
- "stringify(undefined) returned " + s + " expected undfined");
+ "stringify(undefined) returned " + s + " expected
undefined");
var parse_tests = [
["true", true],
@@ -1887,7 +1934,10 @@ ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
["[false,{},{\"x\": []}]", [false,{},{x:[]}]],
["0", 0],
["- 1", -1],
- ["1e2147483648", Infinity]
+ ["1e2147483648", Infinity],
+ ["0.5", 0.5],
+ ["0e5", 0],
+ [".5", 0.5]
];
function json_cmp(x, y) {
@@ -2408,6 +2458,7 @@ var exception_array = {
E_OBJECT_EXPECTED: { type: "TypeError", number: -2146823281 },
E_OBJECT_REQUIRED: { type: "TypeError", number: -2146827864 },
E_UNSUPPORTED_ACTION: { type: "TypeError", number: -2146827843 },
+ E_NOT_ENUMERATOR: { type: "TypeError", number: -2146823273 },
E_NOT_VBARRAY: { type: "TypeError", number: -2146823275 },
E_INVALID_DELETE: { type: "TypeError", number: -2146823276 },
E_UNDEFINED: { type: "TypeError", number: -2146823279 },
@@ -2673,6 +2724,15 @@ testArrayHostThis("join");
testArrayHostThis("pop");
testArrayHostThis("sort");
+function testEnumeratorThis(func) {
+ testThisExcept(Enumerator.prototype[func], "E_NOT_ENUMERATOR");
+}
+
+testEnumeratorThis("atEnd");
+testEnumeratorThis("item");
+testEnumeratorThis("moveFirst");
+testEnumeratorThis("moveNext");
+
function testObjectInherit(obj, constr, ts, tls, vo) {
ok(obj instanceof Object, "obj is not instance of Object");
ok(obj instanceof constr, "obj is not instance of its constructor");
@@ -2965,4 +3025,9 @@ ok(tmp.toArray() == "2,3,12,13,22,23,32,33,42,43",
"tmp.toArray() = " + tmp.toAr
ok(createArray().toArray() == "2,3,12,13,22,23,32,33,42,43",
"createArray.toArray()=" + createArray().toArray());
+obj = new Enumerator();
+ok(obj.atEnd(), "atEnd() = " + obj.atEnd());
+obj.moveFirst();
+ok(obj.atEnd(), "atEnd() = " + obj.atEnd());
+
reportSuccess();
diff --git a/modules/rostests/winetests/jscript/caller.c
b/modules/rostests/winetests/jscript/caller.c
index f09ad90d718..dc97fb72681 100644
--- a/modules/rostests/winetests/jscript/caller.c
+++ b/modules/rostests/winetests/jscript/caller.c
@@ -136,6 +136,9 @@ static void test_change_type(IVariantChangeType *change_type, VARIANT
*src, cons
call_change_type(change_type, &v, src, VT_I4);
ok(V_I4(&v) == ex->int_result, "V_I4(v) = %d, expected %d\n",
V_I4(&v), ex->int_result);
+ call_change_type(change_type, &v, src, VT_UI2);
+ ok(V_UI2(&v) == (UINT16)ex->int_result, "V_UI2(v) = %u, expected
%u\n", V_UI2(&v), (UINT16)ex->int_result);
+
call_change_type(change_type, &v, src, VT_BSTR);
ok(!strcmp_wa(V_BSTR(&v), ex->str_result), "V_BSTR(v) = %s, expected
%s\n", wine_dbgstr_w(V_BSTR(&v)), ex->str_result);
VariantClear(&v);
diff --git a/modules/rostests/winetests/jscript/lang.js
b/modules/rostests/winetests/jscript/lang.js
index 2a30ea35a71..4812a066d15 100644
--- a/modules/rostests/winetests/jscript/lang.js
+++ b/modules/rostests/winetests/jscript/lang.js
@@ -180,6 +180,9 @@ ok(tmp === "undefined", "typeof((new
Object).doesnotexist = " + tmp);
tmp = typeof(testObj.onlyDispID);
ok(tmp === "unknown", "typeof(testObj.onlyDispID) = " + tmp);
+ok("\0\0x\0\0".length === 5, "\"\\0\\0x\\0\\0\".length = "
+ "\0\0x\0\0".length);
+ok("\0\0x\0\0" === String.fromCharCode(0) + "\0x\0" +
String.fromCharCode(0), "\"\\0\\0x\\0\\0\" unexpected");
+
ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
ok(testFunc1.arguments === null, "testFunc1.arguments = " +
testFunc1.arguments);
@@ -1523,7 +1526,7 @@ deleteTest = 1;
delete deleteTest;
try {
tmp = deleteTest;
- ok(false, "deleteTest not throwed exception?");
+ ok(false, "deleteTest did not throw an exception?");
}catch(ex) {}
(function() {
diff --git a/modules/rostests/winetests/jscript/run.c
b/modules/rostests/winetests/jscript/run.c
index 77cd74ebb39..e3f272d46ca 100644
--- a/modules/rostests/winetests/jscript/run.c
+++ b/modules/rostests/winetests/jscript/run.c
@@ -90,7 +90,11 @@ DEFINE_EXPECT(global_success_i);
DEFINE_EXPECT(global_notexists_d);
DEFINE_EXPECT(global_propargput_d);
DEFINE_EXPECT(global_propargput_i);
+DEFINE_EXPECT(global_propargputop_d);
+DEFINE_EXPECT(global_propargputop_get_i);
+DEFINE_EXPECT(global_propargputop_put_i);
DEFINE_EXPECT(global_testargtypes_i);
+DEFINE_EXPECT(global_calleval_i);
DEFINE_EXPECT(puredisp_prop_d);
DEFINE_EXPECT(puredisp_noprop_d);
DEFINE_EXPECT(puredisp_value);
@@ -106,6 +110,10 @@ DEFINE_EXPECT(testobj_noprop_d);
DEFINE_EXPECT(testobj_onlydispid_d);
DEFINE_EXPECT(testobj_onlydispid_i);
DEFINE_EXPECT(testobj_notexists_d);
+DEFINE_EXPECT(testobj_newenum);
+DEFINE_EXPECT(enumvariant_next_0);
+DEFINE_EXPECT(enumvariant_next_1);
+DEFINE_EXPECT(enumvariant_reset);
DEFINE_EXPECT(GetItemInfo_testVal);
DEFINE_EXPECT(ActiveScriptSite_OnScriptError);
DEFINE_EXPECT(invoke_func);
@@ -144,6 +152,9 @@ DEFINE_EXPECT(BindHandler);
#define DISPID_GLOBAL_TESTPROPPUTREF 0x101b
#define DISPID_GLOBAL_GETSCRIPTSTATE 0x101c
#define DISPID_GLOBAL_BINDEVENTHANDLER 0x101d
+#define DISPID_GLOBAL_TESTENUMOBJ 0x101e
+#define DISPID_GLOBAL_CALLEVAL 0x101f
+#define DISPID_GLOBAL_PROPARGPUTOP 0x1020
#define DISPID_GLOBAL_TESTPROPDELETE 0x2000
#define DISPID_GLOBAL_TESTNOPROPDELETE 0x2001
@@ -219,6 +230,101 @@ static void _test_grfdex(unsigned line, DWORD grfdex, DWORD expect)
ok_(__FILE__,line)(grfdex == expect, "grfdex = %x, expected %x\n", grfdex,
expect);
}
+static HRESULT WINAPI EnumVARIANT_QueryInterface(IEnumVARIANT *iface, REFIID riid, void
**ppv)
+{
+ *ppv = NULL;
+
+ if (IsEqualGUID(riid, &IID_IEnumVARIANT))
+ *ppv = iface;
+ else
+ return E_NOINTERFACE;
+
+ return S_OK;
+}
+
+static ULONG WINAPI EnumVARIANT_AddRef(IEnumVARIANT *iface)
+{
+ return 2;
+}
+
+static ULONG WINAPI EnumVARIANT_Release(IEnumVARIANT *iface)
+{
+ return 1;
+}
+
+static int EnumVARIANT_index = 0;
+static int EnumVARIANT_next_0_count = 0;
+static HRESULT WINAPI EnumVARIANT_Next(
+ IEnumVARIANT *This,
+ ULONG celt,
+ VARIANT *rgVar,
+ ULONG *pCeltFetched)
+{
+ ok(rgVar != NULL, "rgVar is NULL\n");
+ ok(celt == 1, "celt = %d\n", celt);
+ ok(pCeltFetched == NULL, "pCeltFetched is not NULL\n");
+
+ if (!rgVar)
+ return S_FALSE;
+
+ if (EnumVARIANT_index == 0)
+ {
+ EnumVARIANT_next_0_count--;
+ if (EnumVARIANT_next_0_count <= 0)
+ CHECK_EXPECT(enumvariant_next_0);
+
+ V_VT(rgVar) = VT_I4;
+ V_I4(rgVar) = 123;
+
+ if (pCeltFetched)
+ *pCeltFetched = 1;
+ EnumVARIANT_index++;
+ return S_OK;
+ }
+
+ CHECK_EXPECT(enumvariant_next_1);
+
+ if (pCeltFetched)
+ *pCeltFetched = 0;
+ return S_FALSE;
+
+}
+
+static HRESULT WINAPI EnumVARIANT_Skip(
+ IEnumVARIANT *This,
+ ULONG celt)
+{
+ ok(0, "EnumVariant_Skip: unexpected call\n");
+ return E_NOTIMPL;
+}
+static HRESULT WINAPI EnumVARIANT_Reset(
+ IEnumVARIANT *This)
+{
+ CHECK_EXPECT(enumvariant_reset);
+ EnumVARIANT_index = 0;
+ return S_OK;
+}
+
+static HRESULT WINAPI EnumVARIANT_Clone(
+ IEnumVARIANT *This,
+ IEnumVARIANT **ppEnum)
+{
+ ok(0, "EnumVariant_Clone: unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static IEnumVARIANTVtbl testEnumVARIANTVtbl = {
+ EnumVARIANT_QueryInterface,
+ EnumVARIANT_AddRef,
+ EnumVARIANT_Release,
+ EnumVARIANT_Next,
+ EnumVARIANT_Skip,
+ EnumVARIANT_Reset,
+ EnumVARIANT_Clone
+};
+
+static IEnumVARIANT testEnumVARIANT = { &testEnumVARIANTVtbl };
+
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void
**ppv)
{
*ppv = NULL;
@@ -252,7 +358,6 @@ static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface,
UINT *pcti
static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
LCID lcid, ITypeInfo **ppTInfo)
{
- ok(0, "unexpected call\n");
return E_NOTIMPL;
}
@@ -321,6 +426,28 @@ static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx
*iface, IUnknown
return E_NOTIMPL;
}
+static HRESULT WINAPI testObj_Invoke(IDispatchEx *iface, DISPID id,
+ REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
+ VARIANT *pvarRes, EXCEPINFO *pei, UINT *puArgErr)
+{
+ switch(id) {
+ case DISPID_NEWENUM:
+ ok(pdp != NULL, "pdp == NULL\n");
+ ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
+ ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
+ ok(pvarRes != NULL, "pvarRes == NULL\n");
+ ok(pei == NULL, "pei != NULL\n");
+
+ CHECK_EXPECT(testobj_newenum);
+ V_VT(pvarRes) = VT_DISPATCH;
+ V_DISPATCH(pvarRes) = (IDispatch*)&testEnumVARIANT;
+ return S_OK;
+ }
+
+ ok(0, "unexpected call %x\n", id);
+ return DISP_E_MEMBERNOTFOUND;
+}
+
static HRESULT WINAPI testObj_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex,
DISPID *pid)
{
if(!strcmp_wa(bstrName, "prop")) {
@@ -454,7 +581,7 @@ static IDispatchExVtbl testObjVtbl = {
DispatchEx_GetTypeInfoCount,
DispatchEx_GetTypeInfo,
DispatchEx_GetIDsOfNames,
- DispatchEx_Invoke,
+ testObj_Invoke,
testObj_GetDispID,
testObj_InvokeEx,
testObj_DeleteMemberByName,
@@ -805,6 +932,13 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR
bstrName, DWORD
return S_OK;
}
+ if(!strcmp_wa(bstrName, "propArgPutOp")) {
+ CHECK_EXPECT(global_propargputop_d);
+ test_grfdex(grfdex, fdexNameCaseSensitive);
+ *pid = DISPID_GLOBAL_PROPARGPUTOP;
+ return S_OK;
+ }
+
if(!strcmp_wa(bstrName, "propArgPutO")) {
CHECK_EXPECT(global_propargput_d);
test_grfdex(grfdex, fdexNameEnsure|fdexNameCaseSensitive);
@@ -862,6 +996,16 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR
bstrName, DWORD
return S_OK;
}
+ if(!strcmp_wa(bstrName, "testEnumObj")) {
+ *pid = DISPID_GLOBAL_TESTENUMOBJ;
+ return S_OK;
+ }
+
+ if(!strcmp_wa(bstrName, "callEval")) {
+ *pid = DISPID_GLOBAL_CALLEVAL;
+ 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;
@@ -1253,6 +1397,55 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID
id, LCID lcid,
ok(V_I4(pdp->rgvarg+2) == 0, "V_I4(pdp->rgvarg+2) = %d\n",
V_I4(pdp->rgvarg+2));
return S_OK;
+ case DISPID_GLOBAL_PROPARGPUTOP:
+ ok(pdp != NULL, "pdp == NULL\n");
+ ok(pdp->rgvarg != NULL, "rgvarg != NULL\n");
+ ok(pei != NULL, "pei == NULL\n");
+
+ switch(wFlags) {
+ case INVOKE_PROPERTYGET | INVOKE_FUNC:
+ CHECK_EXPECT(global_propargputop_get_i);
+
+ ok(pdp->cNamedArgs == 0, "cNamedArgs = %d\n",
pdp->cNamedArgs);
+ ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
+ ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
+ ok(pdp->cNamedArgs == 0, "cNamedArgs = %d\n",
pdp->cNamedArgs);
+ ok(pvarRes != NULL, "pvarRes = NULL\n");
+
+ ok(V_VT(pdp->rgvarg) == VT_I4, "V_VT(pdp->rgvarg) = %d\n",
V_VT(pdp->rgvarg));
+ ok(V_I4(pdp->rgvarg) == 1, "V_I4(pdp->rgvarg) = %d\n",
V_I4(pdp->rgvarg));
+
+ ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) =
%d\n", V_VT(pdp->rgvarg+1));
+ ok(V_I4(pdp->rgvarg+1) == 0, "V_I4(pdp->rgvarg+1) = %d\n",
V_I4(pdp->rgvarg+1));
+
+ V_VT(pvarRes) = VT_I4;
+ V_I4(pvarRes) = 6;
+ break;
+ case INVOKE_PROPERTYPUT:
+ CHECK_EXPECT(global_propargputop_put_i);
+
+ ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n",
pdp->cNamedArgs);
+ ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT,
"pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
+ ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs ==
NULL\n");
+ ok(pdp->cArgs == 3, "cArgs = %d\n", pdp->cArgs);
+ ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n",
pdp->cNamedArgs);
+ ok(!pvarRes, "pvarRes != NULL\n");
+
+ ok(V_VT(pdp->rgvarg) == VT_I4, "V_VT(pdp->rgvarg) = %d\n",
V_VT(pdp->rgvarg));
+ ok(V_I4(pdp->rgvarg) == 8, "V_I4(pdp->rgvarg) = %d\n",
V_I4(pdp->rgvarg));
+
+ ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) =
%d\n", V_VT(pdp->rgvarg+1));
+ ok(V_I4(pdp->rgvarg+1) == 1, "V_I4(pdp->rgvarg+1) = %d\n",
V_I4(pdp->rgvarg+1));
+
+ ok(V_VT(pdp->rgvarg+2) == VT_I4, "V_VT(pdp->rgvarg+2) =
%d\n", V_VT(pdp->rgvarg+2));
+ ok(V_I4(pdp->rgvarg+2) == 0, "V_I4(pdp->rgvarg+2) = %d\n",
V_I4(pdp->rgvarg+2));
+ break;
+ default:
+ ok(0, "wFlags = %x\n", wFlags);
+ }
+
+ return S_OK;
+
case DISPID_GLOBAL_OBJECT_FLAG: {
IDispatchEx *dispex;
BSTR str;
@@ -1315,7 +1508,7 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id,
LCID lcid,
return S_OK;
case DISPID_GLOBAL_TESTARGTYPES: {
- VARIANT args[8], v;
+ VARIANT args[10], v;
DISPPARAMS dp = {args, NULL, ARRAY_SIZE(args), 0};
HRESULT hres;
@@ -1358,7 +1551,11 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID
id, LCID lcid,
V_VT(args+6) = VT_R4;
V_R4(args+6) = 0.5;
V_VT(args+7) = VT_UI2;
- V_R4(args+7) = 3;
+ V_UI2(args+7) = 3;
+ V_VT(args+8) = VT_UI1;
+ V_UI1(args+8) = 4;
+ V_VT(args+9) = VT_I1;
+ V_I1(args+9) = 5;
V_VT(&v) = VT_I4;
V_I4(&v) = 2;
hres = IDispatch_Invoke(V_DISPATCH(pdp->rgvarg), DISPID_VALUE, &IID_NULL,
0, DISPATCH_METHOD, &dp, NULL, NULL, NULL);
@@ -1366,6 +1563,43 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID
id, LCID lcid,
return S_OK;
}
+
+ case DISPID_GLOBAL_CALLEVAL: {
+ IDispatchEx *eval_func;
+ DISPPARAMS params;
+ VARIANT arg, res;
+ HRESULT hres;
+
+ CHECK_EXPECT(global_calleval_i);
+
+ ok(pdp != NULL, "pdp == NULL\n");
+ ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
+ ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
+ ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
+ ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
+ ok(pvarRes == NULL, "pvarRes != NULL\n");
+ ok(pei != NULL, "pei == NULL\n");
+
+ ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(arg) = %d\n",
V_VT(pdp->rgvarg));
+ hres = IDispatch_QueryInterface(V_DISPATCH(pdp->rgvarg), &IID_IDispatchEx,
(void**)&eval_func);
+ ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
+
+ params.rgvarg = &arg;
+ params.rgdispidNamedArgs = NULL;
+ params.cArgs = 1;
+ params.cNamedArgs = 0;
+ V_VT(&arg) = VT_BSTR;
+
+ V_BSTR(&arg) = a2bstr("var x = 5; v");
+ V_VT(&res) = VT_ERROR;
+ hres = IDispatchEx_InvokeEx(eval_func, DISPID_VALUE, 0, DISPATCH_METHOD,
¶ms, &res, NULL, NULL);
+ ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
+ ok(V_VT(&res) == VT_I4, "eval returned type %u\n",
V_VT(&res));
+ ok(V_I4(&res) == 2, "eval returned %d\n", V_I4(&res));
+ SysFreeString(V_BSTR(&arg));
+ IDispatchEx_Release(eval_func);
+ return S_OK;
+ }
}
ok(0, "unexpected call %x\n", id);
@@ -2366,6 +2600,107 @@ static void test_invokeex(void)
IActiveScript_Release(script);
}
+static void test_eval(void)
+{
+ IActiveScriptParse *parser;
+ IDispatchEx *script_dispex;
+ IDispatch *script_disp;
+ IActiveScript *engine;
+ VARIANT arg, res;
+ DISPPARAMS params;
+ DISPID id, v_id;
+ BSTR str;
+ HRESULT hres;
+
+ engine = create_script();
+
+ hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse,
(void**)&parser);
+ ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
+
+ hres = IActiveScriptParse_InitNew(parser);
+ ok(hres == S_OK, "InitNew failed: %08x\n", hres);
+
+ hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
+ ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
+
+ SET_EXPECT(GetItemInfo_testVal);
+ hres = IActiveScript_AddNamedItem(engine, test_valW,
+ SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
+ ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
+ CHECK_CALLED(GetItemInfo_testVal);
+
+ hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
+ ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n",
hres);
+
+ hres = IActiveScript_GetScriptDispatch(engine, NULL, &script_disp);
+ ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
+ ok(script_disp != NULL, "script_disp == NULL\n");
+
+ hres = IDispatch_QueryInterface(script_disp, &IID_IDispatchEx,
(void**)&script_dispex);
+ ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
+ IDispatch_Release(script_disp);
+
+ str = a2bstr("eval");
+ hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id);
+ ok(hres == S_OK, "Could not get eval dispid: %08x\n", hres);
+ SysFreeString(str);
+
+ params.rgvarg = &arg;
+ params.rgdispidNamedArgs = NULL;
+ params.cArgs = 1;
+ params.cNamedArgs = 0;
+ V_VT(&arg) = VT_BSTR;
+
+ V_BSTR(&arg) = a2bstr("var v = 1;");
+ V_VT(&res) = VT_ERROR;
+ hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms,
&res, NULL, NULL);
+ ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
+ ok(V_VT(&res) == VT_EMPTY, "eval returned type %u\n", V_VT(&res));
+ SysFreeString(V_BSTR(&arg));
+
+ V_BSTR(&arg) = a2bstr("v");
+ V_VT(&res) = VT_ERROR;
+ hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms,
&res, NULL, NULL);
+ ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
+ ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res));
+ ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res));
+ SysFreeString(V_BSTR(&arg));
+
+ str = a2bstr("v");
+ hres = IDispatchEx_GetDispID(script_dispex, str, 0, &v_id);
+ ok(hres == S_OK, "Could not get v dispid: %08x\n", hres);
+ SysFreeString(str);
+
+ params.rgvarg = NULL;
+ params.cArgs = 0;
+ V_VT(&res) = VT_ERROR;
+ hres = IDispatchEx_InvokeEx(script_dispex, v_id, 0, DISPATCH_PROPERTYGET,
¶ms, &res, NULL, NULL);
+ ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
+ ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res));
+ ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res));
+
+ SET_EXPECT(global_calleval_i);
+ str = a2bstr("(function(){"
+ " var v = 2;"
+ " callEval(eval);"
+ " ok(x === 5, 'x = ' + x);"
+ "})();");
+ hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0,
NULL, NULL);
+ ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
+ SysFreeString(str);
+ CHECK_CALLED(global_calleval_i);
+
+ str = a2bstr("x");
+ hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id);
+ ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(x) returned %08x\n", hres);
+ SysFreeString(str);
+
+ IDispatchEx_Release(script_dispex);
+ IActiveScriptParse_Release(parser);
+ IActiveScript_Close(engine);
+ IActiveScript_Release(engine);
+}
+
struct bom_test
{
WCHAR str[1024];
@@ -2651,9 +2986,25 @@ static BOOL run_tests(void)
CHECK_CALLED(global_propargput_d);
CHECK_CALLED(global_propargput_i);
+ SET_EXPECT(global_propargputop_d);
+ SET_EXPECT(global_propargputop_get_i);
+ SET_EXPECT(global_propargputop_put_i);
+ parse_script_a("var t=0; propArgPutOp(t++, t++) += t++;");
+ CHECK_CALLED(global_propargputop_d);
+ CHECK_CALLED(global_propargputop_get_i);
+ CHECK_CALLED(global_propargputop_put_i);
+
+ SET_EXPECT(global_propargputop_d);
+ SET_EXPECT(global_propargputop_get_i);
+ SET_EXPECT(global_propargputop_put_i);
+ parse_script_a("var t=0; propArgPutOp(t++, t++) ^= 14;");
+ CHECK_CALLED(global_propargputop_d);
+ CHECK_CALLED(global_propargputop_get_i);
+ CHECK_CALLED(global_propargputop_put_i);
+
SET_EXPECT(global_testargtypes_i);
parse_script_a("testArgTypes(dispUnk, intProp(), intProp, getShort(),
shortProp,"
- "function(ui2,r4,i4ref,ui4,nullunk,d,i,s) {"
+ "function(i1,ui1,ui2,r4,i4ref,ui4,nullunk,d,i,s) {"
" ok(getVT(i) === 'VT_I4', 'getVT(i) = ' +
getVT(i));"
" ok(getVT(s) === 'VT_I4', 'getVT(s) = ' +
getVT(s));"
" ok(getVT(d) === 'VT_DISPATCH', 'getVT(d) = '
+ getVT(d));"
@@ -2666,6 +3017,10 @@ static BOOL run_tests(void)
" ok(r4 === 0.5, 'r4 = ' + r4);"
" ok(getVT(r4) === 'VT_R8', 'getVT(r4) = ' +
getVT(r4));"
" ok(getVT(ui2) === 'VT_I4', 'getVT(ui2) = ' +
getVT(ui2));"
+ " ok(getVT(ui1) === 'VT_I4', 'getVT(ui1) = ' +
getVT(ui1));"
+ " ok(ui1 === 4, 'ui1 = ' + ui1);"
+ " ok(getVT(i1) === 'VT_I4', 'getVT(i1) = ' +
getVT(i1));"
+ " ok(i1 === 5, 'i1 = ' + i1);"
"});");
CHECK_CALLED(global_testargtypes_i);
@@ -2683,6 +3038,46 @@ static BOOL run_tests(void)
CHECK_CALLED(global_success_d);
CHECK_CALLED(global_success_i);
+ EnumVARIANT_index = 0;
+ EnumVARIANT_next_0_count = 1;
+ SET_EXPECT(testobj_newenum);
+ SET_EXPECT(enumvariant_next_0);
+ parse_script_a("new Enumerator(testObj);");
+ CHECK_CALLED(testobj_newenum);
+ CHECK_CALLED(enumvariant_next_0);
+
+ EnumVARIANT_index = 0;
+ EnumVARIANT_next_0_count = 2;
+ SET_EXPECT(testobj_newenum);
+ SET_EXPECT(enumvariant_next_0);
+ SET_EXPECT(enumvariant_reset);
+ parse_script_a("(function () {"
+ " var testEnumObj = new Enumerator(testObj);"
+ " var tmp = testEnumObj.moveFirst();"
+ " ok(tmp == undefined, \"testEnumObj.moveFirst() =
\" + tmp);"
+ "})()");
+ CHECK_CALLED(testobj_newenum);
+ CHECK_CALLED(enumvariant_next_0);
+ CHECK_CALLED(enumvariant_reset);
+
+ EnumVARIANT_index = 0;
+ EnumVARIANT_next_0_count = 1;
+ SET_EXPECT(testobj_newenum);
+ SET_EXPECT(enumvariant_next_0);
+ SET_EXPECT(enumvariant_next_1);
+ parse_script_a("(function () {"
+ " var testEnumObj = new Enumerator(testObj);"
+ " while (!testEnumObj.atEnd())"
+ " {"
+ " ok(testEnumObj.item() == 123, "
+ " \"testEnumObj.item() =
\"+testEnumObj.item());"
+ " testEnumObj.moveNext();"
+ " }"
+ "})()");
+ CHECK_CALLED(testobj_newenum);
+ CHECK_CALLED(enumvariant_next_0);
+ CHECK_CALLED(enumvariant_next_1);
+
run_from_res("lang.js");
run_from_res("api.js");
run_from_res("regexp.js");
@@ -2711,6 +3106,7 @@ static BOOL run_tests(void)
test_script_exprs();
test_invokeex();
+ test_eval();
parse_script_with_error_a(
"?",