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 and pomek committed Sep 25, 2024
1 parent 9c2d297 commit 2c43f71
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 2c43f71

Please sign in to comment.