test: fixup done being called multiple times (#34175)

This commit is contained in:
John Kleinschmidt 2022-05-11 13:23:24 -04:00 committed by GitHub
parent c512993744
commit 6f8a36f404
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3516,9 +3516,14 @@ describe('BrowserWindow module', () => {
describe('beginFrameSubscription method', () => {
it('does not crash when callback returns nothing', (done) => {
const w = new BrowserWindow({ show: false });
let called = false;
w.loadFile(path.join(fixtures, 'api', 'frame-subscriber.html'));
w.webContents.on('dom-ready', () => {
w.webContents.beginFrameSubscription(function () {
// This callback might be called twice.
if (called) return;
called = true;
// Pending endFrameSubscription to next tick can reliably reproduce
// a crash which happens when nothing is returned in the callback.
setTimeout(() => {