| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 | <head> |
| 4 | <title>Config</title> |
| 5 | <link rel="stylesheet" type="text/css" href="../test.css" /> |
| 6 | <script type="text/javascript" src="../../../ckeditor_source.js"></script> |
| 7 | <script type="text/javascript" src="../test.js"></script> |
| 8 | <script type="text/javascript"> |
| 9 | //<![CDATA[ |
| 10 | // Local references. |
| 11 | var assert = CKEDITOR.test.assert; |
| 12 | |
| 13 | var mode = new Array(); |
| 14 | mode[1] = 'wysiwyg'; |
| 15 | mode[2] = 'wysiwyg'; |
| 16 | mode[3] = 'source'; |
| 17 | mode[4] = 'wysiwyg'; |
| 18 | mode[5] = 'source'; |
| 19 | mode[6] = 'source'; |
| 20 | |
| 21 | var startupFocus = new Array(); |
| 22 | startupFocus[1] = true; |
| 23 | startupFocus[2] = false; |
| 24 | startupFocus[3] = true; |
| 25 | startupFocus[4] = true; |
| 26 | startupFocus[5] = false; |
| 27 | startupFocus[6] = true; |
| 28 | |
| 29 | |
| 30 | var testFocus = function( editor, n, forceFocus ) |
| 31 | { |
| 32 | if ( typeof console != 'undefined' ) |
| 33 | console.log('test '+editor.name ); |
| 34 | |
| 35 | if ( startupFocus[n] || forceFocus ) // Has focus. |
| 36 | { |
| 37 | assert.isTrue( ( editor.focusManager && editor.focusManager.hasFocus ) , 'HasFocus is false' ); |
| 38 | assert.isTrue( !!CKEDITOR.currentInstance,' CurrentInstance is null' ); |
| 39 | assert.areSame( CKEDITOR.currentInstance.name, editor.name,' CurrentInstance is wrong' ); |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | assert.isFalse( ( editor.focusManager.hasFocus ) , 'HasFocus is true' ); |
| 44 | |
| 45 | if ( CKEDITOR.currentInstance ) |
| 46 | assert.areNotSame( CKEDITOR.currentInstance.name, editor.name, ' editor'+n+' = CKEDITOR.currentInstance' ); |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | if ( typeof console != 'undefined' ) |
| 51 | { |
| 52 | CKEDITOR.on( 'currentInstance', function() |
| 53 | { |
| 54 | if (CKEDITOR.currentInstance) |
| 55 | console.log(' currentInstance: <b>'+ CKEDITOR.currentInstance.name+ '</b>'); |
| 56 | else |
| 57 | console.log(' currentInstance empty') |
| 58 | }); |
| 59 | } |
| 60 | |
| 61 | CKEDITOR.test.addTestCase( |
| 62 | { |
| 63 | test_config1 : function() |
| 64 | { |
| 65 | var testCase = this, |
| 66 | testNum = 1; |
| 67 | var editor = CKEDITOR.replace( 'editor' + testNum , { |
| 68 | startupFocus: startupFocus[ testNum ], |
| 69 | startupMode : mode[ testNum ], |
| 70 | onLoad : function( editor ) |
| 71 | { |
| 72 | testCase.resume( function() |
| 73 | { |
| 74 | testFocus( editor, testNum ); |
| 75 | } ); |
| 76 | } |
| 77 | }); |
| 78 | |
| 79 | this.wait(); |
| 80 | }, |
| 81 | |
| 82 | test_config2 : function() |
| 83 | { |
| 84 | var testCase = this, |
| 85 | testNum = 2; |
| 86 | var editor = CKEDITOR.replace( 'editor' + testNum , { |
| 87 | startupFocus: startupFocus[ testNum ], |
| 88 | startupMode : mode[ testNum ], |
| 89 | onLoad : function( editor ) |
| 90 | { |
| 91 | testCase.resume( function() |
| 92 | { |
| 93 | testFocus( editor, testNum ); |
| 94 | } ); |
| 95 | } |
| 96 | }); |
| 97 | |
| 98 | this.wait(); |
| 99 | }, |
| 100 | |
| 101 | test_config3 : function() |
| 102 | { |
| 103 | var testCase = this, |
| 104 | testNum = 3; |
| 105 | var editor = CKEDITOR.replace( 'editor' + testNum , { |
| 106 | startupFocus: startupFocus[ testNum ], |
| 107 | startupMode : mode[ testNum ], |
| 108 | onLoad : function( editor ) |
| 109 | { |
| 110 | testCase.resume( function() |
| 111 | { |
| 112 | testFocus( editor, testNum ); |
| 113 | } ); |
| 114 | } |
| 115 | }); |
| 116 | |
| 117 | this.wait(); |
| 118 | }, |
| 119 | |
| 120 | test_config4 : function() |
| 121 | { |
| 122 | var testCase = this, |
| 123 | testNum = 4; |
| 124 | var editor = CKEDITOR.replace( 'editor' + testNum , { |
| 125 | startupFocus: startupFocus[ testNum ], |
| 126 | startupMode : mode[ testNum ], |
| 127 | onLoad : function( editor ) |
| 128 | { |
| 129 | testCase.resume( function() |
| 130 | { |
| 131 | testFocus( editor, testNum ); |
| 132 | } ); |
| 133 | } |
| 134 | }); |
| 135 | |
| 136 | this.wait(); |
| 137 | }, |
| 138 | |
| 139 | test_config5 : function() |
| 140 | { |
| 141 | var testCase = this, |
| 142 | testNum = 5; |
| 143 | var editor = CKEDITOR.replace( 'editor' + testNum , { |
| 144 | startupFocus: startupFocus[ testNum ], |
| 145 | startupMode : mode[ testNum ], |
| 146 | onLoad : function( editor ) |
| 147 | { |
| 148 | testCase.resume( function() |
| 149 | { |
| 150 | testFocus( editor, testNum ); |
| 151 | } ); |
| 152 | } |
| 153 | }); |
| 154 | |
| 155 | this.wait(); |
| 156 | }, |
| 157 | |
| 158 | test_config6 : function() |
| 159 | { |
| 160 | var testCase = this, |
| 161 | testNum = 6; |
| 162 | var editor = CKEDITOR.replace( 'editor' + testNum , { |
| 163 | startupFocus: startupFocus[ testNum ], |
| 164 | startupMode : mode[ testNum ], |
| 165 | onLoad : function( editor ) |
| 166 | { |
| 167 | testCase.resume( function() |
| 168 | { |
| 169 | testFocus( editor, testNum ); |
| 170 | } ); |
| 171 | } |
| 172 | }); |
| 173 | |
| 174 | this.wait(); |
| 175 | }, |
| 176 | |
| 177 | name :document.title |
| 178 | } ); |
| 179 | //]]> |
| 180 | </script> |
| 181 | |
| 182 | |
| 183 | </head> |
| 184 | <body><br><br><br><br><br><br> |
| 185 | <textarea id="editor1" name="editor1"></textarea> |
| 186 | <textarea id="editor2" name="editor2"></textarea> |
| 187 | <textarea id="editor3" name="editor3"></textarea> |
| 188 | <textarea id="editor4" name="editor4"></textarea> |
| 189 | <textarea id="editor5" name="editor5"></textarea> |
| 190 | <textarea id="editor6" name="editor6"></textarea> |
| 191 | <textarea id="editor7" name="editor6"></textarea> |
| 192 | <textarea id="editor8" name="editor6"></textarea> |
| 193 | </body> |
| 194 | </html> |