Skip to content

Commit

Permalink
Merge pull request #17113 from ckeditor/ck/fix-selection-hang-test
Browse files Browse the repository at this point in the history
Tests (engine): Delay selections in `should not enter infinite loop` test due to changes in Chrome 129.
  • Loading branch information
Mati365 authored Sep 19, 2024
2 parents 08f77fd + b30cfbc commit cf5533f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/ckeditor5-engine/tests/view/observer/selectionobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ describe( 'SelectionObserver', () => {
} );

it( 'should not enter infinite loop', () => {
let counter = 70;

const viewFoo = viewDocument.getRoot().getChild( 0 ).getChild( 0 );
view.change( writer => {
writer.setSelection( viewFoo, 0 );
Expand All @@ -315,18 +313,29 @@ describe( 'SelectionObserver', () => {
selectionObserver._clearInfiniteLoop();
viewDocument.on( 'selectionChange', selectionChangeSpy );

let counter = 70;

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

changeDomSelection();
counter--;

setTimeout( simulateSelectionChanges, 10 );
};

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

counter = 0;
resolve();
} );

while ( counter > 0 ) {
changeDomSelection();
counter--;
}
simulateSelectionChanges();
} );
} );

Expand Down

0 comments on commit cf5533f

Please sign in to comment.