diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/arguments/bug1762575-3.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/arguments/bug1762575-3.js')
-rw-r--r-- | js/src/jit-test/tests/arguments/bug1762575-3.js | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/arguments/bug1762575-3.js b/js/src/jit-test/tests/arguments/bug1762575-3.js new file mode 100644 index 0000000000..371eab009f --- /dev/null +++ b/js/src/jit-test/tests/arguments/bug1762575-3.js @@ -0,0 +1,89 @@ +// Test implementation details when arguments object keep strong references +// to their elements. + +function checkWeakRef(f, isCleared = true) { + let [wr, args] = f({}); + + assertEq(wr.deref() !== undefined, true); + + clearKeptObjects(); + gc(); + + // In an ideal world, the reference is always cleared. But in specific + // circumstances we're currently keeping the reference alive. Should this + // ever change, feel free to update this test case accordingly. IOW having + // |isCleared == false| is okay for spec correctness, but it isn't optimal. + assertEq(wr.deref() === undefined, isCleared); +} + +checkWeakRef(function() { + // Create a weak-ref for the first argument. + let wr = new WeakRef(arguments[0]); + + // Clear the reference from the arguments object. + arguments[0] = null; + + // Let the arguments object escape. + return [wr, arguments]; +}); + +checkWeakRef(function() { + // Create a weak-ref for the first argument. + let wr = new WeakRef(arguments[0]); + + // Clear the reference from the arguments object. + Object.defineProperty(arguments, 0, {value: null}); + + // Let the arguments object escape. + return [wr, arguments]; +}); + +checkWeakRef(function self() { + // Create a weak-ref for the first argument. + let wr = new WeakRef(arguments[0]); + + // Delete operation doesn't clear the reference! + delete arguments[0]; + + // Let the arguments object escape. + return [wr, arguments]; +}, /*isCleared=*/ false); + +checkWeakRef(function() { + "use strict"; + + // Create a weak-ref for the first argument. + let wr = new WeakRef(arguments[0]); + + // Clear the reference from the arguments object. + arguments[0] = null; + + // Let the arguments object escape. + return [wr, arguments]; +}); + +checkWeakRef(function() { + "use strict"; + + // Create a weak-ref for the first argument. + let wr = new WeakRef(arguments[0]); + + // This define operation doesn't clear the reference! + Object.defineProperty(arguments, 0, {value: null}); + + // Let the arguments object escape. + return [wr, arguments]; +}, /*isCleared=*/ false); + +checkWeakRef(function() { + "use strict"; + + // Create a weak-ref for the first argument. + let wr = new WeakRef(arguments[0]); + + // Delete operation doesn't clear the reference! + delete arguments[0]; + + // Let the arguments object escape. + return [wr, arguments]; +}, /*isCleared=*/ false); |