Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28
FPIIM-449
Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/test/mjsunit/function-bind.js b/test/mjsunit/function-bind.js
index 4a8f2d2..8269869 100644
--- a/test/mjsunit/function-bind.js
+++ b/test/mjsunit/function-bind.js
@@ -25,7 +25,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Tests the Function.prototype.bind (ES 15.3.4.5) method.
+// Flags: --allow-natives-syntax
+
+// Tests the Function.prototype.bind method.
+
// Simple tests.
function foo(x, y, z) {
@@ -37,24 +40,29 @@
var f = foo.bind(foo);
assertEquals([foo, 3, 1], f(1, 2, 3));
assertEquals(3, f.length);
+assertEquals("function () { [native code] }", f.toString());
f = foo.bind(foo, 1);
assertEquals([foo, 3, 1], f(2, 3));
assertEquals(2, f.length);
+assertEquals("function () { [native code] }", f.toString());
f = foo.bind(foo, 1, 2);
assertEquals([foo, 3, 1], f(3));
assertEquals(1, f.length);
+assertEquals("function () { [native code] }", f.toString());
f = foo.bind(foo, 1, 2, 3);
assertEquals([foo, 3, 1], f());
assertEquals(0, f.length);
+assertEquals("function () { [native code] }", f.toString());
// Test that length works correctly even if more than the actual number
// of arguments are given when binding.
f = foo.bind(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9);
assertEquals([foo, 9, 1], f());
assertEquals(0, f.length);
+assertEquals("function () { [native code] }", f.toString());
// Use a different bound object.
var obj = {x: 42, y: 43};
@@ -74,6 +82,7 @@
f = f_bound_this.bind(obj, 2);
assertEquals(3, f());
assertEquals(0, f.length);
+assertEquals('[object Function]', Object.prototype.toString.call(f));
// Test chained binds.
@@ -268,14 +277,18 @@
// Check that property descriptors are correct (unconfigurable, unenumerable,
// and both get and set is the ThrowTypeError function).
-var cdesc = Object.getOwnPropertyDescriptor(f, "caller");
-var adesc = Object.getOwnPropertyDescriptor(f, "arguments");
+//
+// Poisoned accessors are no longer own properties --- get them from the
+// prototype
+var f_proto = Object.getPrototypeOf(f);
+var cdesc = Object.getOwnPropertyDescriptor(f_proto, "caller");
+var adesc = Object.getOwnPropertyDescriptor(f_proto, "arguments");
assertFalse(cdesc.enumerable);
-assertFalse(cdesc.configurable);
+assertTrue(cdesc.configurable);
assertFalse(adesc.enumerable);
-assertFalse(adesc.configurable);
+assertTrue(adesc.configurable);
assertSame(cdesc.get, cdesc.set);
assertSame(cdesc.get, adesc.get);
@@ -294,3 +307,20 @@
// the caller is strict and the callee isn't. A bound function is built-in,
// but not considered strict.
(function foo() { return foo.caller; }).bind()();
+
+
+(function TestProtoIsPreserved() {
+ function fun() {}
+
+ function proto() {}
+ Object.setPrototypeOf(fun, proto);
+ var bound = fun.bind({});
+ assertEquals(proto, Object.getPrototypeOf(bound));
+
+ var bound2 = fun.bind({});
+ assertTrue(%HaveSameMap(new bound, new bound2));
+
+ Object.setPrototypeOf(fun, null);
+ bound = Function.prototype.bind.call(fun, {});
+ assertEquals(null, Object.getPrototypeOf(bound));
+})();