Skip to content

Commit

Permalink
Fix potential memory leak in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mati365 committed Sep 19, 2024
1 parent ab036a3 commit b30cfbc
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,22 @@ describe( 'SelectionObserver', () => {
let counter = 70;

const simulateSelectionChanges = () => {
if ( !counter ) {
return;
}

changeDomSelection();
counter--;

if ( counter > 0 ) {
setTimeout( simulateSelectionChanges, 10 );
}
setTimeout( simulateSelectionChanges, 10 );
};

return new Promise( resolve => {
viewDocument.on( 'selectionChangeDone', () => {
expect( wasInfiniteLoopDetected ).to.be.true;
expect( selectionChangeSpy.callCount ).to.equal( 60 );

counter = 0;
resolve();
} );

Expand Down

0 comments on commit b30cfbc

Please sign in to comment.