Przeglądaj źródła

Changed trigger value for infinite loop counter from 200 to 60.

Szymon Kupś 8 lat temu
rodzic
commit
9f92735462

+ 2 - 2
packages/ckeditor5-engine/src/view/observer/selectionobserver.js

@@ -148,9 +148,9 @@ export default class SelectionObserver extends Observer {
 		}
 
 		// Ensure we are not in the infinite loop (#400).
-		// This counter is reset every 1 seconds. 200 selection changes in 1 seconds is enough high number
+		// This counter is reset each second. 60 selection changes in 1 second is enough high number
 		// to be very difficult (impossible) to achieve using just keyboard keys (during normal editor use).
-		if ( ++this._loopbackCounter > 200 ) {
+		if ( ++this._loopbackCounter > 60 ) {
 			/**
 			 * Selection change observer detected an infinite rendering loop.
 			 * Most probably you try to put the selection in the position which is not allowed

+ 4 - 4
packages/ckeditor5-engine/tests/view/observer/selectionobserver.js

@@ -138,7 +138,7 @@ describe( 'SelectionObserver', () => {
 
 	it( 'should warn and not enter infinite loop', () => {
 		// Selectionchange event is called twice per `changeDomSelection()` execution.
-		let counter = 105;
+		let counter = 35;
 
 		const viewFoo = viewDocument.getRoot().getChild( 0 ).getChild( 0 );
 		viewDocument.selection.addRange( ViewRange.createFromParentsAndOffsets( viewFoo, 0, viewFoo, 0 ) );
@@ -195,8 +195,8 @@ describe( 'SelectionObserver', () => {
 				clock.restore();
 			} );
 
-		// Selectionchange event is called twice per `changeDomSelection()` execution. We call it 75 times to get
-		// 150 events. Infinite loop counter is reset, so calling this method twice should not show any warning.
+		// Selectionchange event is called twice per `changeDomSelection()` execution. We call it 25 times to get
+		// 50 events. Infinite loop counter is reset, so calling this method twice should not show any warning.
 		function doChanges() {
 			return new Promise( resolve => {
 				viewDocument.once( 'selectionChangeDone', () => {
@@ -204,7 +204,7 @@ describe( 'SelectionObserver', () => {
 					resolve();
 				} );
 
-				for ( let i = 0; i < 75; i++ ) {
+				for ( let i = 0; i < 30; i++ ) {
 					changeDomSelection();
 				}
 			} );