8
0
Эх сурвалжийг харах

Internal: Brought back a test removed in ab63b603094a303f that caused CC drop.

Aleksander Nowodzinski 6 жил өмнө
parent
commit
4f51f0715d

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

@@ -479,6 +479,38 @@ 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, 'warn' );
+
+			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.warn,
+							'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();