JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0
[ckeditor.git] / _source / tests / core / htmlparser / fragment.html
diff --git a/_source/tests/core/htmlparser/fragment.html b/_source/tests/core/htmlparser/fragment.html
new file mode 100644 (file)
index 0000000..9556774
--- /dev/null
@@ -0,0 +1,188 @@
+<!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.htmlParser.fragment</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
+var tc;\r
+\r
+CKEDITOR.test.addTestCase( tc = (function()\r
+{\r
+       // Local reference to the "assert" object.\r
+       var assert = CKEDITOR.test.assert;\r
+\r
+       function testParser( input, expected )\r
+       {\r
+               var fragment = CKEDITOR.htmlParser.fragment.fromHtml( input, 'p' ),\r
+                       writer = new CKEDITOR.htmlParser.basicWriter();\r
+\r
+               fragment.writeHtml( writer );\r
+\r
+               assert.areSame( expected, writer.getHtml( true ) );\r
+       }\r
+\r
+       return {\r
+               test_fromHtml_1 : function()\r
+               {\r
+                       var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<p>Test</p>' );\r
+\r
+                       assert.areSame( 1, fragment.children.length, 'Wrong size' );\r
+                       assert.areSame( CKEDITOR.NODE_ELEMENT, fragment.children[0].type, 'Wrong child type' );\r
+                       assert.areSame( 'p', fragment.children[0].name, 'Wrong child name' );\r
+               },\r
+\r
+               test_parser_1 : function()\r
+               {\r
+                       testParser(     '<table><tr><td>1</td><p><b>2</b> Test</p><td>3</td></tr></table>',\r
+                                               '<p><b>2</b> Test</p><table><tr><td>1</td><td>3</td></tr></table>' );\r
+               },\r
+\r
+               test_parser_2 : function()\r
+               {\r
+                       testParser(     '<b><table><tr><td>1</td><td>2</td></tr></table></b>',\r
+                                               '<table><tr><td><b>1</b></td><td><b>2</b></td></tr></table>' );\r
+               },\r
+\r
+               test_parser_3_1 : function()\r
+               {\r
+                       testParser(     '<b><i>Table:<table><tr><td>1</td><td>2</td></tr></table></i></b>',\r
+                                               '<p><b><i>Table:</i></b></p><table><tr><td><b><i>1</i></b></td><td><b><i>2</i></b></td></tr></table>' );\r
+               },\r
+\r
+               test_parser_3_2 : function()\r
+               {\r
+                       testParser(     '<b><i><table><tr><td>1</td><td>2</td></tr></table>Table</i></b>',\r
+                                               '<table><tr><td><b><i>1</i></b></td><td><b><i>2</i></b></td></tr></table><p><b><i>Table</i></b></p>' );\r
+               },\r
+\r
+               test_parser_4 : function()\r
+               {\r
+                       testParser(     '<b><i>Test',\r
+                                               '<p><b><i>Test</i></b></p>' );\r
+               },\r
+\r
+               test_parser_5 : function()\r
+               {\r
+                       testParser(     '<p>Para 1<p>Para 2<p>Para 3',\r
+                                               '<p>Para 1</p><p>Para 2</p><p>Para 3</p>' );\r
+               },\r
+\r
+               test_parser_6 : function()\r
+               {\r
+                       testParser(     '<b>A</b><i>B</i>',\r
+                                               '<p><b>A</b><i>B</i></p>' );\r
+               },\r
+\r
+               test_parser_7 : function()\r
+               {\r
+                       testParser(     '<p>Para 1<hr>Para 2<h1>Para 3',\r
+                                               '<p>Para 1</p><hr /><p>Para 2</p><h1>Para 3</h1>' );\r
+               },\r
+\r
+               /**\r
+                * Test remove empty inline element.\r
+                */\r
+               test_parser_8 : function()\r
+               {\r
+                       testParser(     '<p><b></b>text</p>',\r
+                                               '<p>text</p>' );\r
+               },\r
+\r
+               /**\r
+                *  Test remove multiple empty inline elements.\r
+                */\r
+               test_parser_8_2 : function()\r
+               {\r
+                       testParser(     '<p><b><i></b></i>text</p>',\r
+                                               '<p>text</p>' );\r
+               },\r
+\r
+               /**\r
+                * Test fixing malformed inline element closing.\r
+                */\r
+               test_parser_9 : function()\r
+               {\r
+                       testParser(     '<p><b>bold<i>ita</b>lic</i></p>',\r
+                                               '<p><b>bold<i>ita</i></b><i>lic</i></p>' );\r
+               },\r
+\r
+               test_ticket_10 : function()\r
+               {\r
+                       testParser(     '<table><tbody><tr><td>A<b></b></td></tr></tbody></table>',\r
+                                               '<table><tbody><tr><td>A</td></tr></tbody></table>' );\r
+               },\r
+\r
+               /**\r
+                *  Test fixing paragraph inside table row.\r
+                */\r
+               test_ticket_3195 : function()\r
+               {\r
+                       testParser(     '<table><tr><td>1</td><p>2</p><td>3</td></tr></table>',\r
+                                               '<p>2</p><table><tr><td>1</td><td>3</td></tr></table>' );\r
+               },\r
+\r
+               /**\r
+                *  Test fixing paragraph inside list.\r
+                */\r
+               test_ticket_3195_2 : function()\r
+               {\r
+                       testParser(     '<ul><li>1</li><p>2</p><li>3</li></ul>',\r
+                                               '<p>2</p><ul><li>1</li><li>3</li></ul>' );\r
+               },\r
+\r
+               /**\r
+                *  Test fixing 'div' inside paragraph.\r
+                */\r
+               test_ticket_3195_3 : function()\r
+               {\r
+                       testParser(     '<p>1<div>2</div><span>3</span></p>',\r
+                                               '<p>1</p><div>2</div><p><span>3</span></p>' );\r
+               },\r
+\r
+               test_ticket_3441 : function()\r
+               {\r
+                       testParser(     '<p><b>Test</b></p><script type="test">var a = "<A Href=xxx>Testing</ A>";\nGo();<\/script>',\r
+                                               '<p><b>Test</b></p><script type="test">var a = "<A Href=xxx>Testing</ A>";\nGo();<\/script>' );\r
+               },\r
+\r
+               test_ticket_3585 : function()\r
+               {\r
+                       testParser(     '<p><br />\t\r\n</p>',\r
+                                               '<p><br /></p>' );\r
+               },\r
+\r
+               test_ticket_3585_1 : function()\r
+               {\r
+                       testParser(     '<p><br />text\t\r\n</p>',\r
+                                               '<p><br />text</p>' );\r
+               },\r
+\r
+               test_ticket_3585_2 : function()\r
+               {\r
+                       testParser(     '<b>inline </b>\n<p>paragraph\t\r\n</p>\t\r\n',\r
+                                               '<p><b>inline </b></p><p>paragraph</p>' );\r
+               },\r
+\r
+               test_ticket_3744 : function()\r
+               {\r
+                       testParser(     '<div><b><font><span>A</font></span></b></div><div>X</div>',\r
+                                               '<div><b><font><span>A</span></font></b></div><div>X</div>' );\r
+               },\r
+\r
+               name : document.title\r
+       };\r
+})() );\r
+\r
+// Uncomment the following to run a single test.\r
+// window.onload = tc.test_ticket_3585_2;\r
+\r
+       //]]>\r
+       </script>\r
+</head>\r
+<body>\r
+</body>\r
+</html>\r