Index: /CKEditor/tests/tt/4574/1.html
===================================================================
--- /CKEditor/tests/tt/4574/1.html	(revision 4416)
+++ /CKEditor/tests/tt/4574/1.html	(revision 4416)
@@ -0,0 +1,175 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+	"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<title>Ticket: #4574 - Merge Cells</title>
+	<meta name="tags" content="editor,unit,drupal">
+	<script type="text/javascript" src="../../cktester/cell.js"></script>
+	<script>
+( function()
+{
+	var ts, tc,
+			assert = CKEDITOR.test.assert,
+			test = CKEDITOR.test;
+	YAHOO.tool.TestRunner.add( ts = new CKEDITOR.test.suites.editorTestSuite(
+		{
+				editorName : 'test_editor',
+				name :document.title
+		} ) );
+
+	ts.add( tc = new YAHOO.tool.TestCase(
+		{
+			/**
+			 * Test merge table cells.
+			 */
+			test_merge_table_cells : function()
+			{
+				var editor = ts.editor;
+				editor.focus();
+				test.setHtmlWithSelection(
+					editor.document.getBody(),
+					test.getValueAsHtml( 'editor_data_with_selection' ) );
+
+				editor.execCommand( 'cellMerge' );
+				assert.areEqual( test.getValueAsHtml( 'editor_data_output' ),
+						test.fixHtml( editor.getData(), false ), 'editor output data doesn\'t match.' );
+			},
+
+			/**
+			 * Test merge table cells with discontinuous selection in Firefox.
+			 */
+			test_merge_table_cells_2 : function()
+			{
+				if( !CKEDITOR.env.gecko )
+					return;
+
+				var editor = ts.editor;
+				test.setHtmlWithSelection(
+					editor.document.getBody(),
+					test.getValueAsHtml( 'editor_data_with_selection_2' ) );
+
+				editor.execCommand( 'cellMerge' );
+				assert.areEqual( test.getValueAsHtml( 'editor_data_output_2' ),
+						test.fixHtml( editor.getData(), false ), 'editor output data doesn\'t match.' );
+			},
+
+			/**
+			 * Test merge table cells.
+			 */
+			test_merge_table_cells_3 : function()
+			{
+				var editor = ts.editor;
+				test.setHtmlWithSelection(
+					editor.document.getBody(),
+					test.getValueAsHtml( 'editor_data_with_selection_3' ) );
+
+				var result = editor.execCommand( 'cellMerge' );
+				assert.areEqual( test.getValueAsHtml( 'editor_data_output_3' ),
+						test.fixHtml( editor.getData(), false ), 'editor output data doesn\'t match.' );
+			}
+		} ) );
+} )();
+	</script>
+</head>
+<body>
+<textarea id="editor_data_with_selection">
+<table>
+    <tbody>
+        <tr>
+            <td rowspan="2">[cell1</td>
+            <td colspan="2">cell2</td>
+        </tr>
+        <tr>
+            <td rowspan="2">cell3</td>
+            <td>cell4</td>
+        </tr>
+        <tr>
+            <td>cell5</td>
+            <td>cell6]</td>
+        </tr>
+    </tbody>
+</table>
+</textarea>
+<textarea id="editor_data_output">
+<table>
+	<tbody>
+		<tr>
+			<td>
+				cell1cell2<br/>
+				cell3cell4<br/>
+				cell5cell6</td>
+		</tr>
+	</tbody>
+</table>
+</textarea>
+<textarea id="editor_data_with_selection_2">
+<table>
+    <tbody>
+        <tr>
+            <td rowspan="2">cell1</td>
+			[
+            <td colspan="2">cell2</td>
+        </tr>
+        <tr>
+            <td rowspan="2">cell3</td>
+            <td>cell4</td>
+			]
+        </tr>
+        <tr>
+            <td>cell5</td>
+            [<td>cell6</td>]
+        </tr>
+    </tbody>
+</table>
+</textarea>
+<textarea id="editor_data_output_2">
+<table>
+	<tbody>
+		<tr>
+			<td rowspan="2">
+				cell1</td>
+			<td colspan="2" rowspan="3">
+				cell2<br/>
+				cell3cell4<br/>
+				cell6</td>
+		</tr>
+		<tr>
+		</tr>
+		<tr>
+			<td>
+				cell5</td>
+		</tr>
+	</tbody>
+</table>
+</textarea>
+<textarea id="editor_data_with_selection_3">
+<table>
+    <tbody>
+        <tr>
+            <td>[cell1</td>
+            <td>cell2]</td>
+        </tr>
+        <tr>
+            <td>cell3</td>
+            <td>cell4</td>
+        </tr>
+    </tbody>
+</table>
+</textarea>
+<textarea id="editor_data_output_3">
+<table>
+	<tbody>
+		<tr>
+			<td colspan="2">
+				cell1cell2</td>
+		</tr>
+		<tr>
+			<td>
+				cell3</td>
+			<td>
+				cell4</td>
+		</tr>
+	</tbody>
+</table>
+</textarea></body>
+</html>
Index: /CKEditor/tests/tt/4574/2.html
===================================================================
--- /CKEditor/tests/tt/4574/2.html	(revision 4416)
+++ /CKEditor/tests/tt/4574/2.html	(revision 4416)
@@ -0,0 +1,390 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+	"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<title>Ticket: #4574 - Split Cell</title>
+	<meta name="tags" content="editor,unit,drupal">
+	<script type="text/javascript" src="../../cktester/cell.js"></script>
+	<script>
+( function()
+{
+	var ts, tc,
+			assert = CKEDITOR.test.assert,
+			test = CKEDITOR.test;
+	YAHOO.tool.TestRunner.add( ts = new CKEDITOR.test.suites.editorTestSuite(
+		{
+				editorName : 'test_editor',
+				name :document.title
+		} ) );
+
+	ts.add( tc = new YAHOO.tool.TestCase(
+		{
+			/**
+			 * Test vertical split a row spanned cell.
+			 */
+			test_vertical_split_table_cells : function()
+			{
+				var editor = ts.editor;
+				editor.focus();
+				test.setHtmlWithSelection(
+					editor.document.getBody(),
+					test.getValueAsHtml( 'editor_data_with_selection' ) );
+
+				editor.execCommand( 'cellVerticalSplit' );
+				assert.areEqual( test.getValueAsHtml( 'editor_data_output' ),
+						test.fixHtml( editor.getData(), false ), 'editor output data doesn\'t match.' );
+			},
+
+			/**
+			 * Test vertical split a simple cell.
+			 */
+			test_vertical_split_table_cells_2 : function()
+			{
+				var editor = ts.editor;
+				test.setHtmlWithSelection(
+					editor.document.getBody(),
+					test.getValueAsHtml( 'editor_data_with_selection_2' ) );
+
+				editor.execCommand( 'cellVerticalSplit' );
+				assert.areEqual( test.getValueAsHtml( 'editor_data_output_2' ),
+						test.fixHtml( editor.getData(), false ), 'editor output data doesn\'t match.' );
+			},
+
+			/**
+			 * Test vertical split a spanned cell with preceedings.
+			 */
+			test_vertical_split_table_cells_3 : function()
+			{
+				var editor = ts.editor;
+				test.setHtmlWithSelection(
+					editor.document.getBody(),
+					test.getValueAsHtml( 'editor_data_with_selection_3' ) );
+
+				editor.execCommand( 'cellVerticalSplit' );
+				assert.areEqual( test.getValueAsHtml( 'editor_data_output_3' ),
+						test.fixHtml( editor.getData(), false ), 'editor output data doesn\'t match.' );
+			},
+
+			/**
+			 * Test horizontal split a row spanned cell.
+			 */
+			test_horizontal_split_table_cells : function()
+			{
+				var editor = ts.editor;
+				editor.focus();
+				test.setHtmlWithSelection(
+					editor.document.getBody(),
+					test.getValueAsHtml( 'editor_data_with_selection_4' ) );
+
+				editor.execCommand( 'cellHorizontalSplit' );
+				assert.areEqual( test.getValueAsHtml( 'editor_data_output_4' ),
+						test.fixHtml( editor.getData(), false ), 'editor output data doesn\'t match.' );
+			},
+
+			/**
+			 * Test horizontal split a simple cell.
+			 */
+			test_horizontal_split_table_cells_2 : function()
+			{
+				var editor = ts.editor;
+				test.setHtmlWithSelection(
+					editor.document.getBody(),
+					test.getValueAsHtml( 'editor_data_with_selection_5' ) );
+
+				editor.execCommand( 'cellHorizontalSplit' );
+				assert.areEqual( test.getValueAsHtml( 'editor_data_output_5' ),
+						test.fixHtml( editor.getData(), false ), 'editor output data doesn\'t match.' );
+			},
+
+			/**
+			 * Test horizontal split a spanned cell with preceedings.
+			 */
+			test_horizontal_split_table_cells_3 : function()
+			{
+				var editor = ts.editor;
+				test.setHtmlWithSelection(
+					editor.document.getBody(),
+					test.getValueAsHtml( 'editor_data_with_selection_6' ) );
+
+				editor.execCommand( 'cellHorizontalSplit' );
+				assert.areEqual( test.getValueAsHtml( 'editor_data_output_6' ),
+						test.fixHtml( editor.getData(), false ), 'editor output data doesn\'t match.' );
+			}
+		} ) );
+} )();
+	</script>
+</head>
+<body>
+<textarea id="editor_data_with_selection">
+<table>
+    <tbody>
+        <tr>
+            <td rowspan="2">^cell1</td>
+            <td colspan="2">cell2</td>
+        </tr>
+        <tr>
+            <td rowspan="2">cell3</td>
+            <td>cell4</td>
+        </tr>
+        <tr>
+            <td>cell5</td>
+            <td>cell6</td>
+        </tr>
+    </tbody>
+</table>
+</textarea>
+<textarea id="editor_data_output">
+<table>
+	<tbody>
+		<tr>
+			<td>
+				cell1</td>
+			<td colspan="2">
+				cell2</td>
+		</tr>
+		<tr>
+			<td>
+				&amp;nbsp;</td>
+			<td rowspan="2">
+				cell3</td>
+			<td>
+				cell4</td>
+		</tr>
+		<tr>
+			<td>
+				cell5</td>
+			<td>
+				cell6</td>
+		</tr>
+	</tbody>
+</table>
+</textarea>
+<textarea id="editor_data_with_selection_2">
+<table>
+    <tbody>
+        <tr>
+            <td rowspan="2">cell1</td>
+            <td colspan="2">cell2</td>
+        </tr>
+        <tr>
+            <td rowspan="2">cell3</td>
+            <td>[cell4]</td>
+        </tr>
+        <tr>
+            <td>cell5</td>
+            <td>cell6</td>
+        </tr>
+    </tbody>
+</table>
+</textarea>
+<textarea id="editor_data_output_2">
+<table>
+	<tbody>
+		<tr>
+			<td rowspan="3">
+				cell1</td>
+			<td colspan="2">
+				cell2</td>
+		</tr>
+		<tr>
+			<td rowspan="3">
+				cell3</td>
+			<td>
+				cell4</td>
+		</tr>
+		<tr>
+			<td>
+				&amp;nbsp;</td>
+		</tr>
+		<tr>
+			<td>
+				cell5</td>
+			<td>
+				cell6</td>
+		</tr>
+	</tbody>
+</table>
+</textarea>
+
+<textarea id="editor_data_with_selection_3">
+<table>
+    <tbody>
+        <tr>
+            <td rowspan="2">cell1</td>
+            <td colspan="2">cell2</td>
+        </tr>
+        <tr>
+            <td rowspan="2">^cell3</td>
+            <td>cell4</td>
+        </tr>
+        <tr>
+            <td>cell5</td>
+            <td>cell6</td>
+        </tr>
+    </tbody>
+</table>
+</textarea>
+<textarea id="editor_data_output_3">
+<table>
+	<tbody>
+		<tr>
+			<td rowspan="2">
+				cell1</td>
+			<td colspan="2">
+				cell2</td>
+		</tr>
+		<tr>
+			<td>
+				cell3</td>
+			<td>
+				cell4</td>
+		</tr>
+		<tr>
+			<td>
+				cell5</td>
+			<td>
+				&amp;nbsp;</td>
+			<td>
+				cell6</td>
+		</tr>
+	</tbody>
+</table>
+</textarea>
+
+<textarea id="editor_data_with_selection_4">
+<table>
+    <tbody>
+        <tr>
+            <td rowspan="2">cell1</td>
+            <td colspan="2">^cell2</td>
+        </tr>
+        <tr>
+            <td rowspan="2">cell3</td>
+            <td>cell4</td>
+        </tr>
+        <tr>
+            <td>cell5</td>
+            <td>cell6</td>
+        </tr>
+    </tbody>
+</table>
+</textarea>
+<textarea id="editor_data_output_4">
+<table>
+	<tbody>
+		<tr>
+			<td rowspan="2">
+				cell1</td>
+			<td>
+				cell2</td>
+			<td>
+				&amp;nbsp;</td>
+		</tr>
+		<tr>
+			<td rowspan="2">
+				cell3</td>
+			<td>
+				cell4</td>
+		</tr>
+		<tr>
+			<td>
+				cell5</td>
+			<td>
+				cell6</td>
+		</tr>
+	</tbody>
+</table>
+</textarea>
+
+<textarea id="editor_data_with_selection_5">
+<table>
+    <tbody>
+        <tr>
+            <td rowspan="2">^cell1</td>
+            <td colspan="2">cell2</td>
+        </tr>
+        <tr>
+            <td rowspan="2">cell3</td>
+            <td>cell4</td>
+        </tr>
+        <tr>
+            <td>cell5</td>
+            <td>cell6</td>
+        </tr>
+    </tbody>
+</table>
+</textarea>
+<textarea id="editor_data_output_5">
+<table>
+	<tbody>
+		<tr>
+			<td rowspan="2">
+				cell1</td>
+			<td rowspan="2">
+				&amp;nbsp;</td>
+			<td colspan="2">
+				cell2</td>
+		</tr>
+		<tr>
+			<td rowspan="2">
+				cell3</td>
+			<td>
+				cell4</td>
+		</tr>
+		<tr>
+			<td colspan="2">
+				cell5</td>
+			<td>
+				cell6</td>
+		</tr>
+	</tbody>
+</table>
+</textarea>
+
+<textarea id="editor_data_with_selection_6">
+<table>
+    <tbody>
+        <tr>
+            <td rowspan="2">cell1</td>
+            <td colspan="2">cell2</td>
+        </tr>
+        <tr>
+            <td rowspan="2">cell3</td>
+            <td>^cell4</td>
+        </tr>
+        <tr>
+            <td>cell5</td>
+            <td>cell6</td>
+        </tr>
+    </tbody>
+</table>
+</textarea>
+<textarea id="editor_data_output_6">
+<table>
+	<tbody>
+		<tr>
+			<td rowspan="2">
+				cell1</td>
+			<td colspan="3">
+				cell2</td>
+		</tr>
+		<tr>
+			<td rowspan="2">
+				cell3</td>
+			<td>
+				cell4</td>
+			<td>
+				&amp;nbsp;</td>
+		</tr>
+		<tr>
+			<td>
+				cell5</td>
+			<td colspan="2">
+				cell6</td>
+		</tr>
+	</tbody>
+</table>
+</textarea>
+
+</body>
+</html>
