Debian Codegraph @

js/src/tests/non262/Function/bound-prototype.js

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 function Bound(fn) {
6 return Function.prototype.bind.call(fn);
7 }
8
9 var fnDefaultPrototype = function(){};
10 assertEq(Object.getPrototypeOf(Bound(fnDefaultPrototype)), Function.prototype);
11
12 var fnGeneratorPrototype = function*(){};
13 assertEq(Object.getPrototypeOf(Bound(fnGeneratorPrototype)), function*(){}.constructor.prototype);
14
15 var fnCustomPrototype = Object.setPrototypeOf(function(){}, Array.prototype);
16 assertEq(Object.getPrototypeOf(Bound(fnCustomPrototype)), Array.prototype);
17
18 var fnNullPrototype = Object.setPrototypeOf(function(){}, null);
19 assertEq(Object.getPrototypeOf(Bound(fnNullPrototype)), null);
20
21
22 function LoggingProxy(target) {
23 var log = [];
24 var proxy = new Proxy(target, new Proxy({}, {
25 get(target, propertyKey, receiver) {
26 log.push(propertyKey);
27 }
28 }));
29 return {proxy, log};
30 }
31
32 var {proxy, log} = LoggingProxy(function(){});
33 Bound(proxy);
34 assertEqArray(log, ["getPrototypeOf", "getOwnPropertyDescriptor", "get", "get"]);
35
36 if (typeof reportCompare === "function")
37 reportCompare(0, 0);