summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/generators/bug1664463.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/generators/bug1664463.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/generators/bug1664463.js')
-rw-r--r--js/src/jit-test/tests/generators/bug1664463.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/generators/bug1664463.js b/js/src/jit-test/tests/generators/bug1664463.js
new file mode 100644
index 0000000000..a6a45b4907
--- /dev/null
+++ b/js/src/jit-test/tests/generators/bug1664463.js
@@ -0,0 +1,31 @@
+// |jit-test| skip-if: !('gc' in this) || !('drainJobQueue' in this)
+// Test that an unused local in an async function is not kept alive by a closure
+// (bug 1412202). Based on a test case by Andy Wingo in bug 1664463.
+
+let nfinalized = 0;
+let finalizers = new FinalizationRegistry(f => { nfinalized++; });
+
+class A {
+ constructor(callback) {
+ this.b = {callback};
+ finalizers.register(this, this.b, this);
+ }
+}
+
+const LOOP_COUNT = 200;
+const FINALIZER_COUNT = 200;
+
+async function main() {
+ for (let j = 0; j < LOOP_COUNT; j++) {
+ for (let i = 0; i < FINALIZER_COUNT; i++) {
+ let console = globalThis.console;
+ let obj = new A(() => console.log("hello"));
+ }
+ drainJobQueue();
+ }
+
+ gc();
+ drainJobQueue();
+ assertEq(nfinalized, LOOP_COUNT * FINALIZER_COUNT, "all objects should be finalized");
+}
+main();