Browse Source

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

Co-authored-by: John Kleinschmidt <[email protected]>
trop[bot] 2 years ago
parent
commit
086d40d566
1 changed files with 5 additions and 0 deletions
  1. 5 0
      spec-main/api-browser-window-spec.ts

+ 5 - 0
spec-main/api-browser-window-spec.ts

@@ -3366,9 +3366,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(() => {