diff options
Diffstat (limited to 'deps/v8/test/mjsunit/harmony/weakrefs/symbol-in-finalizationregistry.js')
-rw-r--r-- | deps/v8/test/mjsunit/harmony/weakrefs/symbol-in-finalizationregistry.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/symbol-in-finalizationregistry.js b/deps/v8/test/mjsunit/harmony/weakrefs/symbol-in-finalizationregistry.js new file mode 100644 index 0000000000..2158143ac3 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/weakrefs/symbol-in-finalizationregistry.js @@ -0,0 +1,30 @@ +// Copyright 2023 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: --harmony-symbol-as-weakmap-key --expose-gc --noincremental-marking + +(async function () { + + let cleanUpCalled = false; + const fg = new FinalizationRegistry((target) => { + assertEquals('123', target); + cleanUpCalled = true; + }); + + (function () { + const innerKey = Symbol('123'); + fg.register(innerKey, '123'); + })(); + + // We need to invoke GC asynchronously and wait for it to finish, so that + // it doesn't need to scan the stack. Otherwise, the objects may not be + // reclaimed because of conservative stack scanning and the test may not + // work as intended. + await gc({ type: 'major', execution: 'async' }); + assertFalse(cleanUpCalled); + + // Check that cleanup callback was called in a follow up task. + setTimeout(() => { assertTrue(cleanUpCalled); }, 0); + +})(); |