diff options
Diffstat (limited to 'deps/v8/test/mjsunit/harmony/weakrefs/finalizationregistry-independent-lifetime-multiple.js')
-rw-r--r-- | deps/v8/test/mjsunit/harmony/weakrefs/finalizationregistry-independent-lifetime-multiple.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/finalizationregistry-independent-lifetime-multiple.js b/deps/v8/test/mjsunit/harmony/weakrefs/finalizationregistry-independent-lifetime-multiple.js new file mode 100644 index 0000000000..4eb54166ea --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/weakrefs/finalizationregistry-independent-lifetime-multiple.js @@ -0,0 +1,32 @@ +// Copyright 2021 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-gc --noincremental-marking --no-concurrent-inlining + +let cleanup_called = false; +function cleanup(holdings) { + cleanup_called = true; +}; +let cleanup_called_2 = false; +function cleanup2(holdings) { + cleanup_called_2 = true; +}; +let fg = new FinalizationRegistry(cleanup); +(function() { + let fg2 = new FinalizationRegistry(cleanup2); + (function() { + fg.register({}, {}); + fg2.register({}, {}); + })(); + // Schedule fg and fg2 for cleanup. + gc(); +})(); + +// Collect fg2, but fg is still alive. +gc(); + +setTimeout(function() { + assertTrue(cleanup_called); + assertFalse(cleanup_called_2); +}, 0); |