Index: _source/tests/core/editor.html
===================================================================
--- _source/tests/core/editor.html (revision 3116)
+++ _source/tests/core/editor.html (working copy)
@@ -14,6 +14,41 @@
{
// Local reference to the "assert" object.
var assert = CKEDITOR.test.assert;
+
+ /**
+ * Load the editor and wait for fully interactable.
+ * @param {Object} elementId
+ * @parma {Object} mode
+ * @param {Object} config
+ * @param {Object} callback Continuation with {@param editor}.
+ * @param {Object} context
+ */
+ function prepareEditor( elementId, mode, config, callback, context )
+ {
+ CKEDITOR.on( 'instanceReady',
+ function( evt )
+ {
+ var isMe = mode == CKEDITOR.ELEMENT_MODE_REPLACE ?
+ evt.editor.name == elementId
+ : evt.editor.element.$ ==
+ document.getElementById( elementId );
+ if ( isMe )
+ {
+ callback.call( context, evt.editor );
+ }
+ }, this );
+
+ mode = mode || CKEDITOR.ELEMENT_MODE_REPLACE;
+ switch( mode )
+ {
+ case CKEDITOR.ELEMENT_MODE_REPLACE :
+ CKEDITOR.replace( elementId, config );
+ break;
+ case CKEDITOR.ELEMENT_MODE_APPENDTO :
+ CKEDITOR.appendTo( elementId, config );
+ break;
+ }
+ }
return {
test_name : function()
@@ -90,6 +125,119 @@
this.wait();
},
+ /**
+ * Test insertHtml on two modes.
+ */
+ test_insertHtml1 : function()
+ {
+ prepareEditor( 'editor4', null, null, function( editor )
+ {
+ this.resume( function()
+ {
+ var htmlData = '
';
+
+ // wysiwyg mode
+ editor.focus();
+ editor.insertHtml( htmlData );
+ assert.areSame( '',
+ editor.getSnapshot() );
+
+ // source mode
+ // sync
+ editor.setMode( 'source' );
+ editor.setData( '' );
+ editor.insertHtml( htmlData );
+ assert.areSame( '', editor.getSnapshot() );
+ } );
+ }, this );
+ this.wait();
+ },
+
+ /**
+ * Test insertElement on two modes.
+ */
+ test_insertElement : function()
+ {
+ prepareEditor( 'editor5', null, null,
+ function( editor )
+ {
+ this.resume( function()
+ {
+
+ var element = CKEDITOR.dom.element
+ .createFromHtml( '' ),
+ expected = '';
+ // wysiwyg mode
+ editor.focus();
+ editor.insertElement( element );
+
+ // Fix enterMode
+ expected += '
';
+ assert.areSame( expected, editor.getSnapshot() );
+
+ // source mode
+ // sync
+ editor.setMode( 'source' );
+ editor.setData( '' );
+ editor.insertElement( element );
+ assert.areSame( '', editor.getSnapshot() );
+ } );
+ }, this );
+ this.wait();
+ },
+
+ /**
+ * Test destroy editor created by replacement.
+ */
+ test_destroy1 : function()
+ {
+ prepareEditor( 'editor6', null, null, function( editor )
+ {
+ this.resume( function()
+ {
+ var loadedContent = 'content';
+ var editorThemeId = 'cke_' + editor.name;
+ var editorElement = editor.element;
+ editor.loadSnapshot( loadedContent );
+ editor.destroy();
+ assert.isUndefined( CKEDITOR.instances[ editor.name ] );
+ assert.isNull( document.getElementById( editorThemeId ) );
+ assert.areSame( loadedContent, document
+ .getElementById( 'editor6' ).value,
+ 'Content of element should get updated.' );
+ assert.areNotSame( 'none', editorElement
+ .getComputedStyle( 'display' ) );
+ } );
+ }, this );
+ this.wait();
+ },
+
+ /**
+ * Test destroy editor created by replacement.
+ */
+ test_destroy2 : function()
+ {
+ var element = CKEDITOR.document.getById( 'editor7' );
+ var content = element.getHtml();
+ prepareEditor( 'editor7',
+ CKEDITOR.ELEMENT_MODE_APPENDTO, null,
+ function( editor )
+ {
+ this.resume( function()
+ {
+ var editorThemeId = 'cke_' + editor.name;
+ var editorElement = editor.element;
+ editor.destroy();
+ assert.isUndefined( CKEDITOR.instances[ editor.name ] );
+ assert.isNull( document.getElementById( editorThemeId ) );
+ assert.areSame( content,
+ document.getElementById( 'editor7' ).innerHTML,
+ 'Original content of element should be restored.' );
+ } );
+ }, this );
+ this.wait();
+ },
+
name : document.title
};
})() );
@@ -101,5 +249,9 @@
+
+
+
+ text