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
|
/* bender-tags: editor */
/* bender-ckeditor-plugins: preview */
bender.editor = {
startupData: '<p>Foo</p>'
};
bender.test( {
'test processing of data on contentPreview': function() {
var tc = this,
editor = tc.editor;
editor.once( 'contentPreview', function( event ) {
event.data.dataValue = event.data.dataValue.replace( 'Foo', 'Bar' );
}, null, null, 1 );
editor.once( 'contentPreview', function( event ) {
tc.resume( function() {
assert.isArray( event.data.dataValue.match( '<p>Bar</p>' ), 'Content has been altered.' );
} );
event.cancel(); // Don't open preview window.
}, null, null, 2 );
editor.execCommand( 'preview' );
tc.wait();
},
// (#3661)
'test createPreview returns new window': function() {
// It's not possible to overwrite window.open in IE8.
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) {
assert.ignore();
}
var openStub = sinon.stub( window, 'open', function() {
return {
document: {
open: function() {},
write: function() {},
close: function() {}
}
};
} ),
returnValue = CKEDITOR.plugins.preview.createPreview( this.editor );
openStub.restore();
assert.isInstanceOf( CKEDITOR.dom.window, returnValue );
},
// (#3661)
'test preview command is available in inline editor': function() {
bender.editorBot.create( {
name: 'inline',
creator: 'inline',
startupData: '<p>Foo</p>',
config: {
plugins: 'preview'
}
}, function( bot ) {
assert.isNotUndefined( bot.editor.getCommand( 'preview' ), 'Command is registered' );
} );
},
// (#3661)
'test preview command is not available in source mode': function() {
bender.editorBot.create( {
name: 'source-test',
startupData: '<p>Foo</p>',
config: {
startupMode: 'source',
plugins: 'preview,sourcearea'
}
}, function( bot ) {
var editor = bot.editor,
previewCommand = editor.getCommand( 'preview' );
assert.isNotUndefined( previewCommand, 'Command is registered' );
assert.areSame( previewCommand.state, CKEDITOR.TRISTATE_DISABLED, 'Command is disabled' );
} );
}
} );
|