Reviewers: rossberg,
Message:
PTAL.
Description:
Fix handling Function.apply for non-array arguments.
[email protected]
TEST=mjsunit/apply,test262
Please review this at http://codereview.chromium.org/8342034/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/runtime.js
M test/mjsunit/apply.js
M test/test262/test262.status
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index
c3554c63723919a27c9d03dff017b1ab0f4fa71a..b6fe69d8c718af9a74f49ddc39ac4732b44eeeef
100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -469,7 +469,7 @@ function APPLY_PREPARE(args) {
}
// Make sure the arguments list has the right type.
- if (args != null && !IS_ARRAY(args) && !IS_ARGUMENTS(args)) {
+ if (args != null && !IS_SPEC_OBJECT(args)) {
throw %MakeTypeError('apply_wrong_args', []);
}
Index: test/mjsunit/apply.js
diff --git a/test/mjsunit/apply.js b/test/mjsunit/apply.js
index
c166110df062ea5f5a56d159b1567e056a6821b6..413ee937c6638cc7d30e2bf75e755a3a89a27d2a
100644
--- a/test/mjsunit/apply.js
+++ b/test/mjsunit/apply.js
@@ -190,3 +190,10 @@ assertEquals("morseper",
"moreseper-prime");
delete(Array.prototype["1"]);
+
+// Check correct handling of non-array argument lists.
+assertSame(this, f0.apply(this, {}), "non-array-1");
+assertSame(this, f0.apply(this, { length:1 }), "non-array-2");
+assertEquals(void 0, f1.apply(this, { length:1 }), "non-array-3");
+assertEquals(void 0, f1.apply(this, { 0:"foo" }), "non-array-4");
+assertEquals("foo", f1.apply(this, { length:1, 0:"foo" }), "non-array-5");
Index: test/test262/test262.status
diff --git a/test/test262/test262.status b/test/test262/test262.status
index
865857c243c2a48f32643a081cfcffd3fd5e4954..20d5b55d5622f43cfd7894a80365b643189152bb
100644
--- a/test/test262/test262.status
+++ b/test/test262/test262.status
@@ -448,15 +448,6 @@ S15.4.4.3_A2_T1: FAIL_OK
# 'P' which is defined as non-configurable (10.6
[[DefineOwnProperty]] step
# 4)
15.2.3.7-6-a-285: FAIL
-# Bug? Strict Mode - 'this' value is a string which cannot be converted to
-# wrapper objects when the function is called with an array of
arguments
-15.3.4.3-1-s: FAIL
-# Bug? Strict Mode - 'this' value is a number which cannot be converted to
-# wrapper objects when the function is called with an array of
arguments
-15.3.4.3-2-s: FAIL
-# Bug? Strict Mode - 'this' value is a boolean which cannot be converted to
-# wrapper objects when the function is called with an array of
arguments
-15.3.4.3-3-s: FAIL
# Bug? Array.prototype.indexOf - decreasing length of array does not delete
# non-configurable properties
15.4.4.14-9-a-19: FAIL
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev