1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
\r
2 <html xmlns="http://www.w3.org/1999/xhtml">
\r
4 <title>CKEDITOR</title>
\r
5 <link rel="stylesheet" type="text/css" href="../test.css" />
\r
6 <script type="text/javascript" src="../../ckeditor.js"></script>
\r
7 <script type="text/javascript" src="../test.js"></script>
\r
8 <script type="text/javascript">
\r
10 // Clean up all instances been created on the page.
\r
11 function removeAllInstances()
\r
13 var allInstances = CKEDITOR.instances;
\r
14 for( var i in allInstances )
\r
16 CKEDITOR.remove( allInstances[ i ] );
\r
20 CKEDITOR.test.addTestCase( (function()
\r
22 // Local reference to the "assert" object.
\r
23 var assert = CKEDITOR.test.assert;
\r
26 test_replaceClass : function()
\r
28 // Asserts the default value.
\r
29 assert.areSame( 'ckeditor', CKEDITOR.replaceClass );
\r
32 test_replaceByClassEnabled : function()
\r
34 // Asserts the default value.
\r
35 assert.isTrue( CKEDITOR.replaceByClassEnabled );
\r
38 test_replaceId : function()
\r
40 CKEDITOR.replace( 'editor1' );
\r
41 assert.isObject( CKEDITOR.instances.editor1, 'editor instance not found' );
\r
42 assert.areSame( 'editor1', CKEDITOR.instances.editor1.name, 'instance name doesn\'t match' );
\r
43 assert.areSame( document.getElementById( 'editor1' ), CKEDITOR.instances.editor1.element.$, 'instance element doesn\'t match' );
\r
46 test_replaceName : function()
\r
48 CKEDITOR.replace( 'editor2' );
\r
49 assert.isObject( CKEDITOR.instances.editor2, 'editor instance not found' );
\r
50 assert.areSame( 'editor2', CKEDITOR.instances.editor2.name, 'instance name doesn\'t match' );
\r
51 assert.areSame( document.getElementsByName( 'editor2' )[0], CKEDITOR.instances.editor2.element.$, 'instance element doesn\'t match' );
\r
54 test_replaceElement : function()
\r
56 CKEDITOR.replace( document.getElementById( 'editor5' ) );
\r
57 assert.isObject( CKEDITOR.instances.editor5, 'editor instance not found' );
\r
58 assert.areSame( 'editor5', CKEDITOR.instances.editor5.name, 'instance name doesn\'t match' );
\r
59 assert.areSame( document.getElementById( 'editor5' ), CKEDITOR.instances.editor5.element.$, 'instance element doesn\'t match' );
\r
63 test_replaceError : function()
\r
67 CKEDITOR.replace( 'error' );
\r
71 assert.areSame( '[CKEDITOR.editor.replace] The element with id or name "error" was not found.', e );
\r
75 test_replaceAll_Class : function()
\r
77 CKEDITOR.replaceAll( 'myclass' );
\r
79 assert.isObject( CKEDITOR.instances.editor3, 'editor3 instance not found' );
\r
80 assert.areSame( 'editor3', CKEDITOR.instances.editor3.name, 'editor3 instance name doesn\'t match' );
\r
81 assert.areSame( document.getElementById( 'editor3' ), CKEDITOR.instances.editor3.element.$, 'editor3 instance element doesn\'t match' );
\r
83 assert.isObject( CKEDITOR.instances.editor4, 'editor4 instance not found' );
\r
84 assert.areSame( 'editor4', CKEDITOR.instances.editor4.name, 'editor4 instance name doesn\'t match' );
\r
85 assert.areSame( document.getElementsByName( 'editor4' )[0], CKEDITOR.instances.editor4.element.$, 'editor4 instance element doesn\'t match' );
\r
87 assert.isUndefined( CKEDITOR.instances.editor6, 'editor6 should be undefined' );
\r
88 assert.isUndefined( CKEDITOR.instances.editor7, 'editor7 should be undefined' );
\r
89 assert.isUndefined( CKEDITOR.instances.editor8, 'editor8 should be undefined' );
\r
90 assert.isUndefined( CKEDITOR.instances.editor8, 'editor9 should be undefined' );
\r
93 test_replaceAll_Function : function()
\r
95 CKEDITOR.replaceAll( function( textarea )
\r
97 return ( textarea.id != 'editor6' && textarea.id != 'editor8' );
\r
100 assert.isObject( CKEDITOR.instances.editor7, 'editor7 instance not found' );
\r
101 assert.areSame( 'editor7', CKEDITOR.instances.editor7.name, 'editor7 instance name doesn\'t match' );
\r
102 assert.areSame( document.getElementById( 'editor7' ), CKEDITOR.instances.editor7.element.$, 'editor7 instance element doesn\'t match' );
\r
104 assert.isObject( CKEDITOR.instances.editor9, 'editor9 instance not found' );
\r
105 assert.areSame( 'editor9', CKEDITOR.instances.editor9.name, 'editor9 instance name doesn\'t match' );
\r
106 assert.areSame( document.getElementById( 'editor9' ), CKEDITOR.instances.editor9.element.$, 'editor9 instance element doesn\'t match' );
\r
108 assert.isUndefined( CKEDITOR.instances.editor6, 'editor6 should be undefined' );
\r
109 assert.isUndefined( CKEDITOR.instances.editor8, 'editor8 should be undefined' );
\r
112 test_replaceAll : function()
\r
114 CKEDITOR.replaceAll();
\r
116 assert.isObject( CKEDITOR.instances.editor6, 'editor6 instance not found' );
\r
117 assert.areSame( 'editor6', CKEDITOR.instances.editor6.name, 'editor6 instance name doesn\'t match' );
\r
118 assert.areSame( document.getElementById( 'editor6' ), CKEDITOR.instances.editor6.element.$, 'editor6 instance element doesn\'t match' );
\r
120 assert.isObject( CKEDITOR.instances.editor8, 'editor8 editor instance not found' );
\r
121 assert.areSame( 'editor8', CKEDITOR.instances.editor8.name, 'editor8 instance name doesn\'t match' );
\r
122 assert.areSame( document.getElementById( 'editor8' ), CKEDITOR.instances.editor8.element.$, 'editor8 instance element doesn\'t match' );
\r
125 test_add : function()
\r
127 var textarea = CKEDITOR.dom.element.createFromHtml( '<textarea id="test_add"><p>test_add</p><\/textarea>' );
\r
128 textarea.appendTo( new CKEDITOR.dom.element( document.body ) );
\r
130 var editor = new CKEDITOR.editor( {}, textarea, CKEDITOR.ELEMENT_MODE_REPLACE );
\r
132 CKEDITOR.add( editor );
\r
134 assert.areSame( editor, CKEDITOR.instances.test_add );
\r
139 removeAllInstances();
\r
142 name : document.title
\r
150 <textarea id="editor1" cols="80" rows="10"></textarea>
\r
151 <textarea name="editor2" cols="80" rows="10"></textarea>
\r
152 <textarea id="editor3" name="editor3" class="myclass" cols="80" rows="10"></textarea>
\r
153 <textarea name="editor4" class="myclass" cols="80" rows="10"></textarea>
\r
154 <textarea id="editor5" cols="80" rows="10"></textarea>
\r
155 <textarea id="editor6" cols="80" rows="10"></textarea>
\r
156 <textarea id="editor7" cols="80" rows="10"></textarea>
\r
157 <textarea id="editor8" cols="80" rows="10"></textarea>
\r
158 <textarea id="editor9" cols="80" rows="10"></textarea>
\r