From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/tests/non262/Array/join-no-has-trap.js | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 js/src/tests/non262/Array/join-no-has-trap.js (limited to 'js/src/tests/non262/Array/join-no-has-trap.js') diff --git a/js/src/tests/non262/Array/join-no-has-trap.js b/js/src/tests/non262/Array/join-no-has-trap.js new file mode 100644 index 0000000000..16b8cbedb1 --- /dev/null +++ b/js/src/tests/non262/Array/join-no-has-trap.js @@ -0,0 +1,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); -- cgit v1.2.3