Commit 357882a8 authored by rossberg@chromium.org's avatar rossberg@chromium.org

`1..isPrototypeOf.call(null)` should return false, not throw TypeError.

BUG=v8:3483
LOG=Y
R=rossberg@chromium.org

Review URL: https://codereview.chromium.org/433413002

Cr-Commit-Position: refs/heads/master@{#25116}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25116 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0b9a70ad
...@@ -252,8 +252,8 @@ function ObjectHasOwnProperty(V) { ...@@ -252,8 +252,8 @@ function ObjectHasOwnProperty(V) {
// ECMA-262 - 15.2.4.6 // ECMA-262 - 15.2.4.6
function ObjectIsPrototypeOf(V) { function ObjectIsPrototypeOf(V) {
CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf");
if (!IS_SPEC_OBJECT(V)) return false; if (!IS_SPEC_OBJECT(V)) return false;
CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf");
return %IsInPrototypeChain(this, V); return %IsInPrototypeChain(this, V);
} }
......
...@@ -162,13 +162,10 @@ for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) { ...@@ -162,13 +162,10 @@ for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) {
var exception = false; var exception = false;
try { try {
// We call all functions with no parameters, which means that essential // We need to pass a dummy object argument ({}) to these functions because
// parameters will have the undefined value. // of Object.prototype.isPrototypeOf's special behavior, see issue 3483
// The test for whether the "this" value is null or undefined is always // for more details.
// performed before access to the other parameters, so even if the should_throw_on_null_and_undefined[i].call(null, {});
// undefined value is an invalid argument value, it mustn't change
// the result of the test.
should_throw_on_null_and_undefined[i].call(null);
} catch (e) { } catch (e) {
exception = true; exception = true;
checkExpectedMessage(e); checkExpectedMessage(e);
...@@ -177,7 +174,7 @@ for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) { ...@@ -177,7 +174,7 @@ for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) {
exception = false; exception = false;
try { try {
should_throw_on_null_and_undefined[i].call(undefined); should_throw_on_null_and_undefined[i].call(undefined, {});
} catch (e) { } catch (e) {
exception = true; exception = true;
checkExpectedMessage(e); checkExpectedMessage(e);
...@@ -186,7 +183,7 @@ for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) { ...@@ -186,7 +183,7 @@ for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) {
exception = false; exception = false;
try { try {
should_throw_on_null_and_undefined[i].apply(null); should_throw_on_null_and_undefined[i].apply(null, [{}]);
} catch (e) { } catch (e) {
exception = true; exception = true;
checkExpectedMessage(e); checkExpectedMessage(e);
...@@ -195,7 +192,7 @@ for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) { ...@@ -195,7 +192,7 @@ for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) {
exception = false; exception = false;
try { try {
should_throw_on_null_and_undefined[i].apply(undefined); should_throw_on_null_and_undefined[i].apply(undefined, [{}]);
} catch (e) { } catch (e) {
exception = true; exception = true;
checkExpectedMessage(e); checkExpectedMessage(e);
...@@ -248,7 +245,9 @@ for (var i = 0; i < non_generic.length; i++) { ...@@ -248,7 +245,9 @@ for (var i = 0; i < non_generic.length; i++) {
// Test that we still throw when calling with thisArg null or undefined // Test that we still throw when calling with thisArg null or undefined
// through an array mapping function. // through an array mapping function.
var array = [1,2,3,4,5]; // We need to make sure that the elements of `array` are all object values,
// see issue 3483 for more details.
var array = [{}, [], new Number, new Map, new WeakSet];
for (var j = 0; j < mapping_functions.length; j++) { for (var j = 0; j < mapping_functions.length; j++) {
for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) { for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) {
exception = false; exception = false;
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
assertFalse(Object.prototype.isPrototypeOf.call());
assertFalse(Object.prototype.isPrototypeOf.call(null, 1));
assertFalse(Object.prototype.isPrototypeOf.call(undefined, 1));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment