8
0
Просмотр исходного кода

Made the missing context error an internal warning.

Maciej Bukowski 6 лет назад
Родитель
Сommit
d92ffad72a
2 измененных файлов с 3 добавлено и 38 удалено
  1. 3 3
      packages/ckeditor5-watchdog/src/watchdog.js
  2. 0 35
      packages/ckeditor5-watchdog/tests/watchdog.js

+ 3 - 3
packages/ckeditor5-watchdog/src/watchdog.js

@@ -349,9 +349,9 @@ export default class Watchdog {
 	 * @param {ErrorEvent|PromiseRejectionEvent} evt Error event.
 	 * @param {ErrorEvent|PromiseRejectionEvent} evt Error event.
 	 */
 	 */
 	_handleError( error, evt ) {
 	_handleError( error, evt ) {
-		if ( error.is && error.is( 'CKEditorError' ) && error.context === undefined ) {
-			console.error( 'The error is missing its context and Watchdog cannot restart the proper editor.' );
-		}
+		// @if CK_DEBUG // if ( error.is && error.is( 'CKEditorError' ) && error.context === undefined ) {
+		// @if CK_DEBUG // console.warn( 'The error is missing its context and Watchdog cannot restart the proper editor.' );
+		// @if CK_DEBUG // }
 
 
 		if ( this._shouldReactToError( error ) ) {
 		if ( this._shouldReactToError( error ) ) {
 			this.crashes.push( {
 			this.crashes.push( {

+ 0 - 35
packages/ckeditor5-watchdog/tests/watchdog.js

@@ -483,38 +483,6 @@ describe( 'Watchdog', () => {
 			} );
 			} );
 		} );
 		} );
 
 
-		it( 'Watchdog should warn if the CKEditorError missing its context', () => {
-			const watchdog = new Watchdog();
-
-			watchdog.setCreator( ( el, config ) => ClassicTestEditor.create( el, config ) );
-			watchdog.setDestructor( editor => editor.destroy() );
-
-			// sinon.stub( window, 'onerror' ).value( undefined ); and similar do not work.
-			const originalErrorHandler = window.onerror;
-			window.onerror = undefined;
-
-			sinon.stub( console, 'error' );
-
-			return watchdog.create( element ).then( () => {
-				setTimeout( () => throwCKEditorError( 'foo' ) );
-
-				return new Promise( res => {
-					setTimeout( () => {
-						window.onerror = originalErrorHandler;
-
-						expect( watchdog.crashes ).to.deep.equal( [] );
-
-						sinon.assert.calledWithExactly(
-							console.error,
-							'The error is missing its context and Watchdog cannot restart the proper editor.'
-						);
-
-						watchdog.destroy().then( res );
-					} );
-				} );
-			} );
-		} );
-
 		it( 'Watchdog should omit error if the CKEditorError context is equal to null', () => {
 		it( 'Watchdog should omit error if the CKEditorError context is equal to null', () => {
 			const watchdog = new Watchdog();
 			const watchdog = new Watchdog();
 
 
@@ -525,8 +493,6 @@ describe( 'Watchdog', () => {
 			const originalErrorHandler = window.onerror;
 			const originalErrorHandler = window.onerror;
 			window.onerror = undefined;
 			window.onerror = undefined;
 
 
-			sinon.stub( console, 'error' );
-
 			return watchdog.create( element ).then( () => {
 			return watchdog.create( element ).then( () => {
 				setTimeout( () => throwCKEditorError( 'foo', null ) );
 				setTimeout( () => throwCKEditorError( 'foo', null ) );
 
 
@@ -535,7 +501,6 @@ describe( 'Watchdog', () => {
 						window.onerror = originalErrorHandler;
 						window.onerror = originalErrorHandler;
 
 
 						expect( watchdog.crashes ).to.deep.equal( [] );
 						expect( watchdog.crashes ).to.deep.equal( [] );
-						sinon.assert.notCalled( console.error );
 
 
 						watchdog.destroy().then( res );
 						watchdog.destroy().then( res );
 					} );
 					} );