JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
bece2beeaf045d3f1b0773c5c487895d32a31cd8
[ckeditor.git] / _source / tests / core / editor.html
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
3 <head>\r
4         <title>CKEDITOR.editor</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
9         //<![CDATA[\r
10 \r
11 // Disable 'scayt' plugin due to it may alter editor config after initialized.\r
12 CKEDITOR.config.removePlugins = 'scayt';\r
13 \r
14 CKEDITOR.test.addTestCase( (function()\r
15 {\r
16         // Local reference to the "assert" object.\r
17         var assert = CKEDITOR.test.assert;\r
18 \r
19         return {\r
20                 test_name : function()\r
21                 {\r
22                         assert.areSame( 'editor1', CKEDITOR.instances.editor1.name );\r
23                 },\r
24 \r
25                 test_element : function()\r
26                 {\r
27                         assert.areSame( document.getElementById( 'editor1' ), CKEDITOR.instances.editor1.element.$ );\r
28                 },\r
29 \r
30                 test_config : function()\r
31                 {\r
32                         // The instance default config must match the CKEDITOR.config.\r
33 \r
34                         var config = CKEDITOR.instances.editor1.config;\r
35 \r
36                         for ( var prop in CKEDITOR.config )\r
37                                 assert.areSame( CKEDITOR.config[ prop ], config[ prop ], '"' + prop + '" doesn\'t match' );\r
38                 },\r
39 \r
40                 test_config_inpage : function()\r
41                 {\r
42                         var self = this;\r
43 \r
44                         CKEDITOR.replace( 'editor2',\r
45                                 {\r
46                                         // The custom setting to be checked.\r
47                                         test1 : 'ball',\r
48                                         baseHref : 'test',\r
49 \r
50                                         on :\r
51                                         {\r
52                                                 instanceReady : function()\r
53                                                 {\r
54                                                         self.resume( function()\r
55                                                         {\r
56                                                                 var config = CKEDITOR.instances.editor2.config;\r
57 \r
58                                                                 assert.areSame( 'ball', config.test1, '"test1" doesn\'t match' );\r
59                                                                 assert.areSame( 'test', config.baseHref, '"baseHref" doesn\'t match' );\r
60 \r
61                                                                 // All other settings must match CKEDITOR.config.\r
62                                                                 for ( var prop in CKEDITOR.config )\r
63                                                                 {\r
64                                                                         if ( prop != 'test1' && prop != 'baseHref' )\r
65                                                                                 assert.areSame( CKEDITOR.config[ prop ], config[ prop ], '"' + prop + '" doesn\'t match' );\r
66                                                                 }\r
67                                                         } );\r
68                                                 }\r
69                                         }\r
70                                 });\r
71 \r
72                         this.wait();\r
73                 },\r
74 \r
75                 test_config_customConfig : function()\r
76                 {\r
77                         var testCase = this;\r
78 \r
79                         CKEDITOR.on( 'instanceCreated', function( event )\r
80                                 {\r
81                                         if ( event.editor.name == 'editor3' )\r
82                                         {\r
83                                                 event.editor.on( 'configLoaded', function()\r
84                                                         {\r
85                                                                 testCase.resume( function()\r
86                                                                 {\r
87                                                                         var config = event.editor.config;\r
88 \r
89                                                                         assert.areSame( 'Ok', config.test_custom1, '"test_custom1" doesn\'t match' );\r
90                                                                         assert.areSame( 'Ok', config.test_custom2, '"test_custom1" doesn\'t match' );\r
91                                                                         assert.areSame( 'ball', config.test1, '"test1" doesn\'t match' );\r
92                                                                         assert.areSame( 'test', config.baseHref, '"baseHref" doesn\'t match' );\r
93 \r
94                                                                         // All other settings must match CKEDITOR.config.\r
95                                                                         for ( var prop in CKEDITOR.config )\r
96                                                                         {\r
97                                                                                 if ( prop != 'customConfig' && prop != 'test_custom1' && prop != 'test_custom2' && prop != 'test1' && prop != 'baseHref' )\r
98                                                                                         assert.areSame( CKEDITOR.config[ prop ], config[ prop ], '"' + prop + '" doesn\'t match' );\r
99                                                                         }\r
100                                                                 });\r
101                                                         });\r
102                                         }\r
103                                 });\r
104 \r
105                         // Pass in-page settings to the instance.\r
106                         CKEDITOR.replace( 'editor3', { customConfig : '_editor/custom_config_1.js', test1 : 'ball', baseHref : 'test' } );\r
107 \r
108                         this.wait();\r
109                 },\r
110 \r
111                 name : document.title\r
112         };\r
113 })() );\r
114 \r
115         //]]>\r
116         </script>\r
117 </head>\r
118 <body>\r
119         <textarea id="editor1" class="ckeditor" cols="80" rows="10"></textarea>\r
120         <textarea id="editor2" cols="80" rows="10"></textarea>\r
121         <textarea id="editor3" cols="80" rows="10"></textarea>\r
122 </body>\r
123 </html>\r