summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Array/join-no-has-trap.js
blob: 16b8cbedb1cee5195d7eb6c8b55cb77f09fb6be7 (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
// Test that Array.prototype.join doesn't call the [[HasProperty]] internal
// method of objects.

var log = [];
var array = [];
var proxy = new Proxy(array, new Proxy({}, {
    get(t, trap, r) {
      return (t, pk, ...more) => {
        log.push(`${trap}:${String(pk)}`);
        return Reflect[trap](t, pk, ...more);
      };
    }
}));

var result;

result = Array.prototype.join.call(proxy);
assertEqArray(log, [ "get:length" ]);
assertEq(result, "");

log.length = 0;
array.push(1);

result = Array.prototype.join.call(proxy);
assertEqArray(log, [ "get:length", "get:0" ]);
assertEq(result, "1");

log.length = 0;
array.push(2);

result = Array.prototype.join.call(proxy);
assertEqArray(log, [ "get:length", "get:0", "get:1" ]);
assertEq(result, "1,2");

if (typeof reportCompare === "function")
  reportCompare(true, true);