diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /js/src/tests/non262/Array/pop-no-has-trap.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/Array/pop-no-has-trap.js')
-rw-r--r-- | js/src/tests/non262/Array/pop-no-has-trap.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/js/src/tests/non262/Array/pop-no-has-trap.js b/js/src/tests/non262/Array/pop-no-has-trap.js new file mode 100644 index 0000000000..11bb93ddd0 --- /dev/null +++ b/js/src/tests/non262/Array/pop-no-has-trap.js @@ -0,0 +1,58 @@ +// Test that Array.prototype.pop doesn't call the [[HasProperty]] internal +// method of objects when retrieving the element at the last index. + +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.pop.call(proxy); +assertEqArray(log, [ + "get:length", + "set:length", "getOwnPropertyDescriptor:length", "defineProperty:length" +]); +assertEq(result, undefined); + +log.length = 0; +array.push(1); + +result = Array.prototype.pop.call(proxy); +assertEqArray(log, [ + "get:length", + "get:0", "deleteProperty:0", + "set:length", "getOwnPropertyDescriptor:length", "defineProperty:length" +]); +assertEq(result, 1); + +log.length = 0; +array.push(2, 3); + +result = Array.prototype.pop.call(proxy); +assertEqArray(log, [ + "get:length", + "get:1", "deleteProperty:1", + "set:length", "getOwnPropertyDescriptor:length", "defineProperty:length" +]); +assertEq(result, 3); + +log.length = 0; +array.push(4, 5); + +result = Array.prototype.pop.call(proxy); +assertEqArray(log, [ + "get:length", + "get:2", "deleteProperty:2", + "set:length", "getOwnPropertyDescriptor:length", "defineProperty:length" +]); +assertEq(result, 5); + +if (typeof reportCompare === "function") + reportCompare(true, true); |