1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/* bender-tags: editor */
/* bender-ckeditor-plugins: floatingspace,toolbar,about,format */
CKEDITOR.focusManager._.blurDelay = 0;
bender.editor = {
startupData: 'foo'
};
bender.test( {
assertFocus: function( truly ) {
var ed = this.editor,
fm = this.editor.focusManager;
assert[ truly === false ? 'isFalse' : 'isTrue' ]( fm.hasFocus, 'check focusManager.hasFocus' );
assert[ truly === false ? 'isFalse' : 'isTrue' ]( ed.container.hasClass( 'cke_focus' ), ' editor container receives focused class name.' );
},
'test editor focus - editable focused': function() {
var bot = this.editorBot;
bot.focus( function() {
this.assertFocus();
} );
},
'test editor blur - focus move out of editor': function() {
var tc = this;
var outer = CKEDITOR.document.getById( 'focusable' );
bender.tools.focus( outer, function() {
tc.assertFocus( false );
} );
},
'test editor focus - combo opened': function() {
var bot = this.editorBot;
bot.combo( 'Format', function( combo ) {
this.assertFocus();
combo._.panel.hide();
} );
},
'test editor focus - dialog opened': function() {
var bot = this.editorBot;
bot.dialog( 'about', function( dialog ) {
this.assertFocus();
dialog.hide();
} );
},
'test editor focus - toolbar focused': function() {
var bot = this.editorBot;
bot.execCommand( 'toolbarFocus' );
// IEs move focus asynchronously in some cases...
wait( function() {
this.assertFocus();
}, 100 );
},
// https://dev.ckeditor.com/ticket/11647
'test inheriting the initial focus': function() {
var el = CKEDITOR.document.createElement( 'div' );
CKEDITOR.document.getBody().append( el );
el.setAttribute( 'contenteditable', true );
el.focus();
var editor = CKEDITOR.inline( el ),
focusWasFired = 0;
editor.on( 'focus', function() {
focusWasFired += 1;
} );
editor.on( 'instanceReady', function() {
resume( function() {
assert.isTrue( editor.focusManager.hasFocus, 'hasFocus after init' );
assert.areSame( editor.editable(), editor.focusManager.currentActive, 'currentActive after init' );
assert.areSame( 1, focusWasFired, 'focus event was fired once' );
editor.on( 'blur', function() {
resume( function() {
assert.isFalse( editor.focusManager.hasFocus, 'hasFocus after destroy' );
editor.destroy();
} );
} );
CKEDITOR.document.getById( 'focusable' ).focus();
wait();
} );
} );
wait();
}
} );
|