// ECMA-262 - 15.2.4.6
function ObjectIsPrototypeOf(V) {
- CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf");
if (!IS_SPEC_OBJECT(V)) return false;
+ CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf");
return %IsInPrototypeChain(this, V);
}
var exception = false;
try {
- // We call all functions with no parameters, which means that essential
- // parameters will have the undefined value.
- // The test for whether the "this" value is null or undefined is always
- // performed before access to the other parameters, so even if the
- // 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);
+ // We need to pass a dummy object argument ({}) to these functions because
+ // of Object.prototype.isPrototypeOf's special behavior, see issue 3483
+ // for more details.
+ should_throw_on_null_and_undefined[i].call(null, {});
} catch (e) {
exception = true;
checkExpectedMessage(e);
exception = false;
try {
- should_throw_on_null_and_undefined[i].call(undefined);
+ should_throw_on_null_and_undefined[i].call(undefined, {});
} catch (e) {
exception = true;
checkExpectedMessage(e);
exception = false;
try {
- should_throw_on_null_and_undefined[i].apply(null);
+ should_throw_on_null_and_undefined[i].apply(null, [{}]);
} catch (e) {
exception = true;
checkExpectedMessage(e);
exception = false;
try {
- should_throw_on_null_and_undefined[i].apply(undefined);
+ should_throw_on_null_and_undefined[i].apply(undefined, [{}]);
} catch (e) {
exception = true;
checkExpectedMessage(e);
// Test that we still throw when calling with thisArg null or undefined
// 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 i = 0; i < should_throw_on_null_and_undefined.length; i++) {
exception = false;
--- /dev/null
+// 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));