assets/ckeditor/tests/plugins/imagebase/features/caption.js
/* Simulate focusing and blurring image widget with caption, asserting caption visibility
	 * during each step.
	 *
	 * @param {Object} options
	 * @param {String} options.fixture Fixture's id.
	 * @param {Boolean} options.initial Caption visibility at the start of the test.
	 * @param {Boolean} options.focus Caption visibility after calling focus function.
	 * @param {Boolean} options.blur Caption visibility after calling blur function.
	 * @param {Function} [options.onInit] Callback to run at the beginning of the test.
	 * @param {Function} [options.onFocus] Callback to run after focus function.
	 * @param {Function} [options.onBlur] Callback to run after blur function.
	 * @param {Function} [options.customFocus] Function to be called instead of default focus function.
	 * @param {Function} [options.customBlur] Function to be called instead of default blur function.
	 */
Simulate focusing and blurring image widget with caption, asserting caption visibility
during each step.

@param {Object} options
@param {String} options.fixture Fixture's id.
@param {Boolean} options.initial Caption visibility at the start of the test.
@param {Boolean} options.focus Caption visibility after calling focus function.
@param {Boolean} options.blur Caption visibility after calling blur function.
@param {Function} [options.onInit] Callback to run at the beginning of the test.
@param {Function} [options.onFocus] Callback to run after focus function.
@param {Function} [options.onBlur] Callback to run after blur function.
@param {Function} [options.customFocus] Function to be called instead of default focus function.
@param {Function} [options.customBlur] Function to be called instead of default blur function.
Simulate focusing and blurring image widget with caption asserting caption visibility during each step . @param { Object } options @param { String } options . fixture Fixture ' s id . @param { Boolean } options . initial Caption visibility at the start of the test . @param { Boolean } options . focus Caption visibility after calling focus function . @param { Boolean } options . blur Caption visibility after calling blur function . @param { Function } [ options . onInit ] Callback to run at the beginning of the test . @param { Function } [ options . onFocus ] Callback to run after focus function . @param { Function } [ options . onBlur ] Callback to run after blur function . @param { Function } [ options . customFocus ] Function to be called instead of default focus function . @param { Function } [ options . customBlur ] Function to be called instead of default blur function .
function createToggleTest( options ) {
		return function( editor, bot ) {
			addTestWidget( editor );
			editor.focus();
			bot.setData( getFixture( options.fixture ), function() {
				var widget = widgetTestsTools.getWidgetByDOMOffset( editor, 0 ),
					caption = widget.parts.caption,
					focusTrap = editor.editable().findOne( 'p' ).getChild( 0 ),
					range = editor.createRange();
				assertVisibility( caption, options.initial, 'caption visibility (initial)' );
				if ( options.onInit ) {
					options.onInit( widget );
				}
				if ( options.customFocus ) {
					options.customFocus( widget );
				} else {
					widget.focus();
				}
				assertVisibility( caption, options.focus, 'caption visibility (focus)' );
				if ( options.onFocus ) {
					options.onFocus( widget );
				}
				if ( options.customBlur ) {
					options.customBlur.call( this, widget );
				} else {
					range.setStart( focusTrap, 1 );
					range.collapse();
					range.select();
				}
				assertVisibility( caption, options.blur, 'caption visibility (blur)' );
				if ( options.onBlur ) {
					options.onBlur( widget );
				}
			} );
		};
	}
function createToggleTest ( options ) { return function ( editor , bot ) { addTestWidget ( editor ) ; editor . focus ( ) ; bot . setData ( getFixture ( options . fixture ) , function ( ) { var widget = widgetTestsTools . getWidgetByDOMOffset ( editor , 0 ) , caption = widget . parts . caption , focusTrap = editor . editable ( ) . findOne ( 'p' ) . getChild ( 0 ) , range = editor . createRange ( ) ; assertVisibility ( caption , options . initial , 'caption visibility (initial)' ) ; if ( options . onInit ) { options . onInit ( widget ) ; } if ( options . customFocus ) { options . customFocus ( widget ) ; } else { widget . focus ( ) ; } assertVisibility ( caption , options . focus , 'caption visibility (focus)' ) ; if ( options . onFocus ) { options . onFocus ( widget ) ; } if ( options . customBlur ) { options . customBlur . call ( this , widget ) ; } else { range . setStart ( focusTrap , 1 ) ; range . collapse ( ) ; range . select ( ) ; } assertVisibility ( caption , options . blur , 'caption visibility (blur)' ) ; if ( options . onBlur ) { options . onBlur ( widget ) ; } } ) ; } ; }
Simulate focusing and blurring image widget with caption, asserting caption visibility
 during each step.
Simulate focusing and blurring image widget with caption asserting caption visibility during each step .
// Make sure the editor is focused, otherwise Edge/IE11 will throw Permission Denied error.