refactor: allocate gin_helper::internal::Event on cpp heap (#48161)

This commit is contained in:
Robo 2025-08-27 09:30:50 +09:00 committed by GitHub
commit e0db4046b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 156 additions and 116 deletions

View file

@ -76,4 +76,30 @@ describe('cpp heap', () => {
expect(result).to.equal(true);
});
});
describe('internal event', () => {
it('should record as node in heap snapshot', async () => {
const { remotely } = await startRemoteControlApp(['--expose-internals']);
const result = await remotely(async (heap: string, snapshotHelper: string) => {
const { BrowserWindow } = require('electron');
const { once } = require('node:events');
const { recordState } = require(heap);
const { containsRetainingPath } = require(snapshotHelper);
const w = new BrowserWindow({
show: false
});
await w.loadURL('about:blank');
const state = recordState();
const isClosed = once(w, 'closed');
w.destroy();
await isClosed;
const eventNativeStackReference = containsRetainingPath(state.snapshot, ['C++ native stack roots', 'Electron / Event']);
const noPersistentReference = !containsRetainingPath(state.snapshot, ['C++ Persistent roots', 'Electron / Event']);
return eventNativeStackReference && noPersistentReference;
}, path.join(__dirname, '../../third_party/electron_node/test/common/heap'),
path.join(__dirname, 'lib', 'heapsnapshot-helpers.js'));
expect(result).to.equal(true);
});
});
});