Index: /FCKtest/config.js
===================================================================
--- /FCKtest/config.js	(revision 1451)
+++ /FCKtest/config.js	(revision 1452)
@@ -1,6 +1,6 @@
 var FCKTestConfig = 
 {
-	BasePath : "/fcktest",
-	EditorPath : "/fckeditor"
+	BasePath : "/FCKeditor/FCKtest",
+	EditorPath : "/FCKeditor/trunk"
 };
 
Index: /FCKtest/fckeditor/ts/visual/1355/1355.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355.html	(revision 1452)
@@ -0,0 +1,233 @@
+<html>
+	<!-- 
+	How does this test work?
+	1. Selenium loads HTML contents and selection into the editing frame of FCKeditor.
+	2. Selenium executes a command in FCKeditor.
+	3. Selenium checks whether FCKeditor's DOM tree output is similar to what we expect.
+
+	The three-step sequence above should be good as a template for other automated feature tests.
+	The third step is a heuristics algorithm, it might need further refinements to the algorithm
+	to support testing other features.
+	-->
+	<head>
+		<title>Tests for #1355</title>
+		<script type="text/javascript" src="../../../../config.js"></script>
+	</head>
+	<body>
+		<table cellpadding="1" cellspacing="1" border="1">
+			<tbody>
+				<tr>
+					<td rowspan="1" colspan="3">Tests for #1355</td>
+				</tr>
+				<tr>
+					<td>selectFrame</td>
+					<td>id=FCKeditor1___Frame</td>
+					<td></td>
+				</tr>
+				<!-- Tests 1 to 5 tests converting from <P> to <PRE>. -->
+				<!-- Test 1: Converting BR nodes into \n with the Formatted format -->
+				<tr>
+					<td>fckLoadContents</td>
+					<td>${CURRENTPATH}/1355/test_format_input1.html</td>
+					<td></td>
+				</tr>
+				<tr>
+					<td>waitForCondition</td>
+					<td>
+						win = selenium.browserbot.getCurrentWindow() ;
+						win.FCKStyles.GetStyle( '_FCK_pre' ).ApplyToSelection( win.FCK.EditorWindow );
+						true ;
+					</td>
+					<td>500</td>
+				</tr>
+				<tr>
+					<td>fckCheckSimilarTo</td>
+					<td>${CURRENTPATH}/1355/test_format_input1_results.html</td>
+					<td></td>
+				</tr>
+				<!-- Test 2: Whitespace compression with the Formatted format -->
+				<tr>
+					<td>fckLoadContents</td>
+					<td>${CURRENTPATH}/1355/test_format_input2.html</td>
+					<td></td>
+				</tr>
+				<tr>
+					<td>waitForCondition</td>
+					<td>
+						win = selenium.browserbot.getCurrentWindow() ;
+						win.FCKStyles.GetStyle( '_FCK_pre' ).ApplyToSelection( win.FCK.EditorWindow );
+						true ;
+					</td>
+					<td>500</td>
+				</tr>
+				<tr>
+					<td>fckCheckSimilarTo</td>
+					<td>${CURRENTPATH}/1355/test_format_input2_results.html</td>
+					<td></td>
+				</tr>
+				<!-- Test 3: &nbsp; conversion with the Formatted format -->
+				<tr>
+					<td>fckLoadContents</td>
+					<td>${CURRENTPATH}/1355/test_format_input3.html</td>
+					<td></td>
+				</tr>
+				<tr>
+					<td>waitForCondition</td>
+					<td>
+						win = selenium.browserbot.getCurrentWindow() ;
+						win.FCKStyles.GetStyle( '_FCK_pre' ).ApplyToSelection( win.FCK.EditorWindow );
+						true ;
+					</td>
+					<td>500</td>
+				</tr>
+				<tr>
+					<td>fckCheckSimilarTo</td>
+					<td>${CURRENTPATH}/1355/test_format_input3_results.html</td>
+					<td></td>
+				</tr>
+				<!-- Test 4: No &nbsp; and extra whitespaces. -->
+				<tr>
+					<td>fckLoadContents</td>
+					<td>${CURRENTPATH}/1355/test_format_input4.html</td>
+					<td></td>
+				</tr>
+				<tr>
+					<td>waitForCondition</td>
+					<td>
+						win = selenium.browserbot.getCurrentWindow() ;
+						win.FCKStyles.GetStyle( '_FCK_pre' ).ApplyToSelection( win.FCK.EditorWindow );
+						true ;
+					</td>
+					<td>500</td>
+				</tr>
+				<tr>
+					<td>fckCheckSimilarTo</td>
+					<td>${CURRENTPATH}/1355/test_format_input4_results.html</td>
+					<td></td>
+				</tr>
+				<!-- Test 5: Weird custom attributes in tags. -->
+				<tr>
+					<td>fckLoadContents</td>
+					<td>${CURRENTPATH}/1355/test_format_input5.html</td>
+					<td></td>
+				</tr>
+				<tr>
+					<td>waitForCondition</td>
+					<td>
+						win = selenium.browserbot.getCurrentWindow() ;
+						win.FCKStyles.GetStyle( '_FCK_pre' ).ApplyToSelection( win.FCK.EditorWindow );
+						true ;
+					</td>
+					<td>500</td>
+				</tr>
+				<tr>
+					<td>fckCheckSimilarTo</td>
+					<td>${CURRENTPATH}/1355/test_format_input5_results.html</td>
+					<td>attr,attr2</td>
+				</tr>
+				<!-- Tests 6 to 10 tests converting from <PRE> to <P>. -->
+				<!-- Test 6: Converting linebreaks in <PRE> to <BR> in <P>. -->
+				<tr>
+					<td>fckLoadContents</td>
+					<td>${CURRENTPATH}/1355/test_format_input6.html</td>
+					<td></td>
+				</tr>
+				<tr>
+					<td>waitForCondition</td>
+					<td>
+						win = selenium.browserbot.getCurrentWindow() ;
+						win.FCKStyles.GetStyle( '_FCK_p' ).ApplyToSelection( win.FCK.EditorWindow );
+						true ;
+					</td>
+					<td>500</td>
+				</tr>
+				<tr>
+					<td>fckCheckSimilarTo</td>
+					<td>${CURRENTPATH}/1355/test_format_input6_results.html</td>
+					<td></td>
+				</tr>
+				<!-- Test 7: Converting contiguous spaces in <PRE> to &nbsp; sequences in <P>. -->
+				<tr>
+					<td>fckLoadContents</td>
+					<td>${CURRENTPATH}/1355/test_format_input7.html</td>
+					<td></td>
+				</tr>
+				<tr>
+					<td>waitForCondition</td>
+					<td>
+						win = selenium.browserbot.getCurrentWindow() ;
+						win.FCKStyles.GetStyle( '_FCK_p' ).ApplyToSelection( win.FCK.EditorWindow );
+						true ;
+					</td>
+					<td>500</td>
+				</tr>
+				<tr>
+					<td>fckCheckSimilarTo</td>
+					<td>${CURRENTPATH}/1355/test_format_input7_results.html</td>
+					<td></td>
+				</tr>
+				<!-- Test 8: Unrendered whitespaces and linebreaks near <PRE> and </PRE>. -->
+				<tr>
+					<td>fckLoadContents</td>
+					<td>${CURRENTPATH}/1355/test_format_input8.html</td>
+					<td></td>
+				</tr>
+				<tr>
+					<td>waitForCondition</td>
+					<td>
+						win = selenium.browserbot.getCurrentWindow() ;
+						win.FCKStyles.GetStyle( '_FCK_p' ).ApplyToSelection( win.FCK.EditorWindow );
+						true ;
+					</td>
+					<td>500</td>
+				</tr>
+				<tr>
+					<td>fckCheckSimilarTo</td>
+					<td>${CURRENTPATH}/1355/test_format_input8_results.html</td>
+					<td></td>
+				</tr>
+				<!-- Test 9: Linebreak just before </PRE> should not be truncated if it is followed by whitespaces. -->
+				<tr>
+					<td>fckLoadContents</td>
+					<td>${CURRENTPATH}/1355/test_format_input9.html</td>
+					<td></td>
+				</tr>
+				<tr>
+					<td>waitForCondition</td>
+					<td>
+						win = selenium.browserbot.getCurrentWindow() ;
+						win.FCKStyles.GetStyle( '_FCK_p' ).ApplyToSelection( win.FCK.EditorWindow );
+						true ;
+					</td>
+					<td>500</td>
+				</tr>
+				<tr>
+					<td>fckCheckSimilarTo</td>
+					<td>${CURRENTPATH}/1355/test_format_input9_results.html</td>
+					<td></td>
+				</tr>
+				<!-- Test 10: Weird custom attributes in tags. -->
+				<tr>
+					<td>fckLoadContents</td>
+					<td>${CURRENTPATH}/1355/test_format_input10.html</td>
+					<td></td>
+				</tr>
+				<tr>
+					<td>waitForCondition</td>
+					<td>
+						win = selenium.browserbot.getCurrentWindow() ;
+						win.FCKStyles.GetStyle( '_FCK_p' ).ApplyToSelection( win.FCK.EditorWindow );
+						true ;
+					</td>
+					<td>500</td>
+				</tr>
+				<tr>
+					<td>fckCheckSimilarTo</td>
+					<td>${CURRENTPATH}/1355/test_format_input10_results.html</td>
+					<td></td>
+				</tr>
+			</tbody>
+		</table>
+	</body>
+	<script type="text/javascript">FCKTestUtils.ProcessBody();</script>
+</html>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input1.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input1.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input1.html	(revision 1452)
@@ -0,0 +1,3 @@
+<p>Line<span id="SelStart" _fck_bookmark="true"></span> 1<br />
+Line 2<br />
+L<span id="SelEnd" _fck_bookmark="true"></span>ine 3</p>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input10.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input10.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input10.html	(revision 1452)
@@ -0,0 +1,6 @@
+<pre>
+    Some
+<span id="SelStart" _fck_bookmark="true"></span><span id="SelEnd" _fck_bookmark="true"></span>
+
+<b attr=" >123<  >>456<<  <<789>> '' " attr2=' ><"<<<a<b>>c> """" '>    sample</b>
+</pre>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input10_results.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input10_results.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input10_results.html	(revision 1452)
@@ -0,0 +1,6 @@
+<p>
+&nbsp;&nbsp;&nbsp;&nbsp;Some<br />
+<br />
+<br />
+<b attr=" >123<  >>456<<  <<789>> '' " attr2=' ><"<<<a<b>>c> """" '>&nbsp;&nbsp;&nbsp;&nbsp;sample</b>
+</p>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input1_results.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input1_results.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input1_results.html	(revision 1452)
@@ -0,0 +1,4 @@
+<pre>
+Line 1
+Line 2
+Line 3</pre>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input2.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input2.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input2.html	(revision 1452)
@@ -0,0 +1,22 @@
+<p>
+
+
+Line<span id="SelStart" _fck_bookmark="true"></span> 
+	
+
+
+			1	
+    
+<br />
+
+
+
+Line
+			2             
+
+
+
+
+<br />
+			L<span id="SelEnd" _fck_bookmark="true"></span>ine    3
+    			     </p>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input2_results.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input2_results.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input2_results.html	(revision 1452)
@@ -0,0 +1,4 @@
+<pre>
+Line 1
+Line 2
+Line 3</pre>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input3.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input3.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input3.html	(revision 1452)
@@ -0,0 +1,3 @@
+<p>&nbsp;&nbsp;Line<span id="SelStart" _fck_bookmark="true"></span> 1<br />
+&nbsp;&nbsp;Line 2<br />
+L<span id="SelEnd" _fck_bookmark="true"></span>ine&nbsp;&nbsp;&nbsp;3</p>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input3_results.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input3_results.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input3_results.html	(revision 1452)
@@ -0,0 +1,4 @@
+<pre>
+  Line 1
+  Line 2
+Line   3</pre>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input4.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input4.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input4.html	(revision 1452)
@@ -0,0 +1,1 @@
+<p>Line<span id="SelStart" _fck_bookmark="true"></span> 1<br />Line 2<br />L<span id="SelEnd" _fck_bookmark="true"></span>ine 3</p>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input4_results.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input4_results.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input4_results.html	(revision 1452)
@@ -0,0 +1,4 @@
+<pre>
+Line 1
+Line 2
+Line 3</pre>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input5.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input5.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input5.html	(revision 1452)
@@ -0,0 +1,3 @@
+<p>Line<span id="SelStart" _fck_bookmark="true"></span> 1<br />
+<b attr="<<   ''     >>" attr2='>  "   ><  "   <'>Line 2</b><br />
+L<span id="SelEnd" _fck_bookmark="true"></span>ine 3</p>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input5_results.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input5_results.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input5_results.html	(revision 1452)
@@ -0,0 +1,4 @@
+<pre>
+Line 1
+<b attr="<<   ''     >>" attr2='>  "   ><  "   <'>Line 2</b>
+Line 3</pre>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input6.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input6.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input6.html	(revision 1452)
@@ -0,0 +1,3 @@
+<pre>Line<span id="SelStart" _fck_bookmark="true"></span> 1
+Line 2
+L<span id="SelEnd" _fck_bookmark="true"></span>ine 3</pre>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input6_results.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input6_results.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input6_results.html	(revision 1452)
@@ -0,0 +1,3 @@
+<p>Line 1<br />
+Line 2<br />
+Line 3</p>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input7.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input7.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input7.html	(revision 1452)
@@ -0,0 +1,3 @@
+<pre> Line<span id="SelStart" _fck_bookmark="true"></span>   1
+Line  2
+L<span id="SelEnd" _fck_bookmark="true"></span>ine   3</pre>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input7_results.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input7_results.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input7_results.html	(revision 1452)
@@ -0,0 +1,3 @@
+<p>&nbsp;Line&nbsp;&nbsp; 1<br />
+Line&nbsp;&nbsp;2<br />
+Line&nbsp;&nbsp; 3</p>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input8.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input8.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input8.html	(revision 1452)
@@ -0,0 +1,5 @@
+<pre>                               
+ Line<span id="SelStart" _fck_bookmark="true"></span>   1
+Line  2
+L<span id="SelEnd" _fck_bookmark="true"></span>ine   3 
+</pre>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input8_results.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input8_results.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input8_results.html	(revision 1452)
@@ -0,0 +1,3 @@
+<p>&nbsp;Line&nbsp;&nbsp; 1<br />
+Line&nbsp;&nbsp;2<br />
+Line&nbsp;&nbsp; 3&nbsp;</p>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input9.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input9.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input9.html	(revision 1452)
@@ -0,0 +1,5 @@
+<pre>                               
+ Line<span id="SelStart" _fck_bookmark="true"></span>   1
+Line  2
+L<span id="SelEnd" _fck_bookmark="true"></span>ine   3 
+ </pre>
Index: /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input9_results.html
===================================================================
--- /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input9_results.html	(revision 1452)
+++ /FCKtest/fckeditor/ts/visual/1355/1355/test_format_input9_results.html	(revision 1452)
@@ -0,0 +1,4 @@
+<p>&nbsp;Line&nbsp;&nbsp; 1<br />
+Line&nbsp;&nbsp;2<br />
+Line&nbsp;&nbsp; 3 <br />
+&nbsp;</p>
Index: /FCKtest/runners/selenium/scripts/user-extensions.js
===================================================================
--- /FCKtest/runners/selenium/scripts/user-extensions.js	(revision 1451)
+++ /FCKtest/runners/selenium/scripts/user-extensions.js	(revision 1452)
@@ -91,9 +91,13 @@
 
 // I can't implement the following as an isXyz function in Selenium because it involves Ajax calls and thus timeouts
-Selenium.prototype.doFckCheckSimilarTo = function( url )
+Selenium.prototype.doFckCheckSimilarTo = function( url, watchAttributes )
 {
 	var win = this.browserbot.getCurrentWindow() ;
 	var editorBody = win.FCK.EditorDocument.body.cloneNode( true ) ;
 	var verifyBody = document.createElement( 'body' ) ;
+	if ( watchAttributes && watchAttributes.length )
+		watchAttributes = watchAttributes.split( ',' ) ;
+	else
+		watchAttributes = [] ;
 	var waitFunc = function()
 	{
@@ -119,8 +123,21 @@
 				throw new SeleniumError( "DOM structure mismatch: missing DOM node in verification document - "
 					       + editorNode.nodeName + " expected." ) ;
-			if ( editorNode.nodeType == 1 && editorNode.nodeName != verifyNode.nodeName )
-				throw new SeleniumError( "DOM structure mismatch: element tags are different - "
-					       + editorNode.nodeName + " encountered in editor document while "
-					       + verifyNode.nodeName + " is expected by verification document." ) ;
+			if ( editorNode.nodeType == 1 )
+			{	if ( editorNode.nodeName != verifyNode.nodeName )
+					throw new SeleniumError( "DOM structure mismatch: element tags are different - "
+						       + editorNode.nodeName + " encountered in editor document while "
+						       + verifyNode.nodeName + " is expected by verification document." ) ;
+				for ( var i = 0 ; i < watchAttributes.length ; i++ )
+				{
+					var attrName = watchAttributes[i] ;
+					if ( editorNode.getAttribute( attrName ) != verifyNode.getAttribute( attrName ) )
+						throw new SeleniumError( "DOM structure mismatch: Element attribute \"" + attrName +
+								"\" is different - " +
+								attrName + "=" + editorNode.getAttribute( attrName ) +
+								" encountered in editor document while " +
+								attrName + "=" + verifyNode.getAttribute( attrName ) +
+								" is expected by verification document." ) ;
+				}
+			}
 			if ( editorNode.nodeType == 3 && editorNode.nodeValue != verifyNode.nodeValue )
 				throw new SeleniumError( "DOM structure mismatch: text node values are different - "
Index: /FCKtest/tests.js
===================================================================
--- /FCKtest/tests.js	(revision 1451)
+++ /FCKtest/tests.js	(revision 1452)
@@ -56,5 +56,5 @@
 			"interactive" :
 			[
-				["1514/test1.html", "#1514: Floating panel positioning"],
+				["1514/test1.html", "#1514: Floating panel positioning"]
 			],
 			"visual" :
@@ -66,5 +66,6 @@
 						"testcase" : 
 						[
-							["loader.html", "Load FCKeditor"]
+							["loader.html", "Load FCKeditor"],
+							["1355/1355.html", "Tests for #1355"]
 						]
 					}
