JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0
[ckeditor.git] / _source / tests / core / editor.html
diff --git a/_source/tests/core/editor.html b/_source/tests/core/editor.html
new file mode 100644 (file)
index 0000000..bece2be
--- /dev/null
@@ -0,0 +1,123 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml">\r
+<head>\r
+       <title>CKEDITOR.editor</title>\r
+       <link rel="stylesheet" type="text/css" href="../test.css" />\r
+       <script type="text/javascript" src="../../ckeditor.js"></script>\r
+       <script type="text/javascript" src="../test.js"></script>\r
+       <script type="text/javascript">\r
+       //<![CDATA[\r
+\r
+// Disable 'scayt' plugin due to it may alter editor config after initialized.\r
+CKEDITOR.config.removePlugins = 'scayt';\r
+\r
+CKEDITOR.test.addTestCase( (function()\r
+{\r
+       // Local reference to the "assert" object.\r
+       var assert = CKEDITOR.test.assert;\r
+\r
+       return {\r
+               test_name : function()\r
+               {\r
+                       assert.areSame( 'editor1', CKEDITOR.instances.editor1.name );\r
+               },\r
+\r
+               test_element : function()\r
+               {\r
+                       assert.areSame( document.getElementById( 'editor1' ), CKEDITOR.instances.editor1.element.$ );\r
+               },\r
+\r
+               test_config : function()\r
+               {\r
+                       // The instance default config must match the CKEDITOR.config.\r
+\r
+                       var config = CKEDITOR.instances.editor1.config;\r
+\r
+                       for ( var prop in CKEDITOR.config )\r
+                               assert.areSame( CKEDITOR.config[ prop ], config[ prop ], '"' + prop + '" doesn\'t match' );\r
+               },\r
+\r
+               test_config_inpage : function()\r
+               {\r
+                       var self = this;\r
+\r
+                       CKEDITOR.replace( 'editor2',\r
+                               {\r
+                                       // The custom setting to be checked.\r
+                                       test1 : 'ball',\r
+                                       baseHref : 'test',\r
+\r
+                                       on :\r
+                                       {\r
+                                               instanceReady : function()\r
+                                               {\r
+                                                       self.resume( function()\r
+                                                       {\r
+                                                               var config = CKEDITOR.instances.editor2.config;\r
+\r
+                                                               assert.areSame( 'ball', config.test1, '"test1" doesn\'t match' );\r
+                                                               assert.areSame( 'test', config.baseHref, '"baseHref" doesn\'t match' );\r
+\r
+                                                               // All other settings must match CKEDITOR.config.\r
+                                                               for ( var prop in CKEDITOR.config )\r
+                                                               {\r
+                                                                       if ( prop != 'test1' && prop != 'baseHref' )\r
+                                                                               assert.areSame( CKEDITOR.config[ prop ], config[ prop ], '"' + prop + '" doesn\'t match' );\r
+                                                               }\r
+                                                       } );\r
+                                               }\r
+                                       }\r
+                               });\r
+\r
+                       this.wait();\r
+               },\r
+\r
+               test_config_customConfig : function()\r
+               {\r
+                       var testCase = this;\r
+\r
+                       CKEDITOR.on( 'instanceCreated', function( event )\r
+                               {\r
+                                       if ( event.editor.name == 'editor3' )\r
+                                       {\r
+                                               event.editor.on( 'configLoaded', function()\r
+                                                       {\r
+                                                               testCase.resume( function()\r
+                                                               {\r
+                                                                       var config = event.editor.config;\r
+\r
+                                                                       assert.areSame( 'Ok', config.test_custom1, '"test_custom1" doesn\'t match' );\r
+                                                                       assert.areSame( 'Ok', config.test_custom2, '"test_custom1" doesn\'t match' );\r
+                                                                       assert.areSame( 'ball', config.test1, '"test1" doesn\'t match' );\r
+                                                                       assert.areSame( 'test', config.baseHref, '"baseHref" doesn\'t match' );\r
+\r
+                                                                       // All other settings must match CKEDITOR.config.\r
+                                                                       for ( var prop in CKEDITOR.config )\r
+                                                                       {\r
+                                                                               if ( prop != 'customConfig' && prop != 'test_custom1' && prop != 'test_custom2' && prop != 'test1' && prop != 'baseHref' )\r
+                                                                                       assert.areSame( CKEDITOR.config[ prop ], config[ prop ], '"' + prop + '" doesn\'t match' );\r
+                                                                       }\r
+                                                               });\r
+                                                       });\r
+                                       }\r
+                               });\r
+\r
+                       // Pass in-page settings to the instance.\r
+                       CKEDITOR.replace( 'editor3', { customConfig : '_editor/custom_config_1.js', test1 : 'ball', baseHref : 'test' } );\r
+\r
+                       this.wait();\r
+               },\r
+\r
+               name : document.title\r
+       };\r
+})() );\r
+\r
+       //]]>\r
+       </script>\r
+</head>\r
+<body>\r
+       <textarea id="editor1" class="ckeditor" cols="80" rows="10"></textarea>\r
+       <textarea id="editor2" cols="80" rows="10"></textarea>\r
+       <textarea id="editor3" cols="80" rows="10"></textarea>\r
+</body>\r
+</html>\r