blob: fe5773032afa1c857c9aba476c9ba945bbe3c622 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// Copyright (C) 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.prototype.isprototypeof
description: >
Object.prototype.isPrototypeOf returns true if either parameter V
and O refer to the same object or O is in [[Prototype]] chain of V.
info: |
Object.prototype.isPrototypeOf ( V )
...
3. Repeat,
a. Set V to ? V.[[GetPrototypeOf]]().
b. If V is null, return false.
c. If SameValue(O, V) is true, return true.
---*/
function USER_FACTORY(name) {
this.name = name;
this.getName = function() {
return name;
};
}
function FORCEDUSER_FACTORY(name, grade) {
this.name = name;
this.grade = grade;
this.getGrade = function() {
return grade;
};
}
var proto = new USER_FACTORY("noname");
FORCEDUSER_FACTORY.prototype = proto;
var luke = new FORCEDUSER_FACTORY("Luke Skywalker", 12);
assert.sameValue(proto.isPrototypeOf(luke), true);
assert.sameValue(USER_FACTORY.prototype.isPrototypeOf(luke), true);
assert.sameValue(Number.isPrototypeOf(luke), false);
reportCompare(0, 0);
|