chore: remove test usages of createIDWeakMap (#24116)

This commit is contained in:
Jeremy Rose 2020-06-15 13:56:51 -07:00 committed by GitHub
parent 8412aae231
commit c0182bca15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 11 deletions

View file

@ -841,18 +841,18 @@ describe('Menu module', function () {
menu.popup({ window: w });
// Keep a weak reference to the menu.
const v8Util = process.electronBinding('v8_util');
const map = v8Util.createIDWeakMap<Electron.Menu>();
map.set(0, menu);
// eslint-disable-next-line no-undef
const wr = new (globalThis as any).WeakRef(menu);
setTimeout(() => {
// Do garbage collection, since |menu| is not referenced in this closure
// it would be gone after next call.
const v8Util = process.electronBinding('v8_util');
v8Util.requestGarbageCollectionForTesting();
setTimeout(() => {
// Try to receive menu from weak reference.
if (map.has(0)) {
map.get(0)!.closePopup();
if (wr.deref()) {
wr.deref().closePopup();
done();
} else {
done('Menu is garbage-collected while popuping');