Index: /CKEditor/tests/tt/6604/1.html
===================================================================
--- /CKEditor/tests/tt/6604/1.html	(revision 6502)
+++ /CKEditor/tests/tt/6604/1.html	(revision 6502)
@@ -0,0 +1,320 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+	"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<title>Ticket: #6604 - BIDI and allignment in entermode=BR</title>
+	<meta name="tags" content="editor,unit,all">
+	<script type="text/javascript" src="../../cktester/cell.js"></script>
+	<script>
+( function()
+{
+	var ts, tc, assert = CKEDITOR.test.assert, test = CKEDITOR.test, selector = YAHOO.util.Selector;
+
+	YAHOO.tool.TestRunner.add( ts = new CKEDITOR.test.suites.editorTestSuite(
+		{
+				editorName : 'test_editor_1',
+				config : { enterMode : CKEDITOR.ENTER_BR },
+				name :document.title
+		} ) );
+
+	ts.add( tc = new YAHOO.tool.TestCase(
+		{
+			setUp : function ()
+			{
+				// Force result data un-formatted.
+				ts.editor.dataProcessor.writer._.rules = {};
+				ts.editor.focus();
+
+			},
+			//Switch to RTL
+			test_set_rtl: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_1' ),
+					output = '<div dir="rtl">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'bidirtl' );
+				assert.areSame(  output, editor.getData() );	
+			},
+			//Switch back to LTR
+			test_set_ltr: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_2' ),
+					output = '<div>paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+					
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'bidiltr' );
+				assert.areSame(  output, editor.getData() );	
+			},
+			//Justify LTR	
+			test_set_justify: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_1' ),
+					outputGecko = '<div style="text-align: justify;">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					outputOpera = '<div style="text-align: justify">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					output = '<div style="text-align: justify; ">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyblock' );
+				assert.areSame(  CKEDITOR.env.gecko? outputGecko : CKEDITOR.env.opera? outputOpera : output, editor.getData() );	
+			},
+			
+			test_set_justify_disable: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_1' ),
+					output = '<div>paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyblock' );
+				this.wait( function ()
+				{
+					editor.execCommand( 'justifyblock' );				
+					assert.areSame(  output, editor.getData() );
+				}, 500 );
+			},
+			//Left LTR
+			test_set_left: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_1' ),
+					outputGecko = '<div>paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					outputOpera = '<div>paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					output = '<div style="text-align: left; ">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyleft' );
+				this.wait( function ()
+				{		
+					assert.areSame(  CKEDITOR.env.opera? outputOpera : output, editor.getData() );
+				}, 500 );
+			},
+			
+			test_set_left_disable: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_1' ),
+					output = '<div>paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				this.wait( function ()
+				{
+					editor.execCommand( 'justifyleft' );
+					this.wait( function ()
+					{
+						editor.execCommand( 'justifyleft' );				
+						assert.areSame(  output, editor.getData() );
+					}, 500 );
+				}, 500 );
+			},
+			//Right LTR
+			test_set_right: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_1' ),
+					outputGecko = '<div style="text-align: right;">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					outputOpera = '<div style="text-align: right">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					output = '<div style="text-align: right; ">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyright' );
+				assert.areSame(  CKEDITOR.env.gecko? outputGecko : CKEDITOR.env.opera? outputOpera : output, editor.getData() );	
+			},
+			
+			test_set_right_disable: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_1' ),
+					output = '<div>paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyright' );
+				this.wait( function ()
+				{
+					editor.execCommand( 'justifyright' );				
+					assert.areSame(  output, editor.getData() );
+				}, 500 );
+			},
+			//Center LTR
+			test_set_center: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_1' ),
+					outputGecko = '<div style="text-align: center;">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					outputOpera = '<div style="text-align: center">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					output = '<div style="text-align: center; ">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifycenter' );
+				assert.areSame(  CKEDITOR.env.gecko? outputGecko : CKEDITOR.env.opera? outputOpera : output, editor.getData() );
+			},
+			
+			test_set_center_disable: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_1' ),
+					output = '<div>paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifycenter' );
+				this.wait( function ()
+				{
+					editor.execCommand( 'justifycenter' );				
+					assert.areSame(  output, editor.getData() );
+				}, 500 );
+			},
+			//Justify RTL
+			test_set_justify_enable_rtl: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_2' ),
+					outputGecko = '<div dir="rtl" style="text-align: justify;">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					outputOpera = '<div dir="rtl" style="text-align: justify">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					output = '<div dir="rtl" style="text-align: justify; ">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyblock' );
+				assert.areSame(  CKEDITOR.env.gecko? outputGecko : CKEDITOR.env.opera? outputOpera : output, editor.getData() );	
+			},
+			
+			test_set_justify_disable_rtl: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_2' ),
+					output = '<div dir="rtl">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyblock' );
+				
+				this.wait( function ()
+				{
+					editor.execCommand('justifyblock' );				
+					assert.areSame(  output, editor.getData() );
+				}, 1000 );	
+			},
+			//Left RTL
+			test_set_left_rtl: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_2' ),
+					outputGecko = '<div dir="rtl" style="text-align: left;">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					outputOpera = '<div dir="rtl" style="text-align: left">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					output = '<div dir="rtl" style="text-align: left; ">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyleft' );
+				assert.areSame(  CKEDITOR.env.gecko? outputGecko : CKEDITOR.env.opera? outputOpera : output, editor.getData() );	
+			},
+			
+			test_set_left_disable_rtl: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_2' ),
+					output = '<div dir="rtl">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyleft' );
+				
+				this.wait( function ()
+				{
+					editor.execCommand('justifyleft' );				
+					assert.areSame(  output, editor.getData() );
+				}, 500 );	
+			},
+			//Right RTL
+			test_set_right_rtl: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_2' ),
+					outputGecko = '<div dir="rtl">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					outputOpera = '<div dir="rtl">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					output = '<div dir="rtl" style="text-align: right; ">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyright' );
+				assert.areSame(  CKEDITOR.env.gecko? outputGecko : CKEDITOR.env.opera? outputOpera : output, editor.getData() );	
+			},
+			
+			test_set_right_disable_rtl: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_2' ),
+					output = '<div dir="rtl">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifyright' );
+				
+				this.wait( function ()
+				{
+					editor.execCommand('justifyright' );				
+					assert.areSame(  output, editor.getData() );
+				}, 500 );	
+			},
+			//Center RTL
+			test_set_center_rtl: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_2' ),
+					outputGecko = '<div dir="rtl" style="text-align: center;">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					outputOpera = '<div dir="rtl" style="text-align: center">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>',
+					output = '<div dir="rtl" style="text-align: center; ">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifycenter' );
+				assert.areSame(  CKEDITOR.env.gecko? outputGecko : CKEDITOR.env.opera? outputOpera : output, editor.getData() );	
+			},
+			
+			test_set_center_disable_rtl: function()
+			{
+				var editor = ts.editor,
+					contentWithSelection = test.getValueAsHtml( 'input_2' ),
+					output = '<div dir="rtl">paragraph 1<br /> paragraph 2<br /> paragraph 3</div>';
+			
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				editor.execCommand( 'selectAll' );
+				editor.execCommand( 'justifycenter' );
+				
+				this.wait( function ()
+				{
+					editor.execCommand('justifycenter' );				
+					assert.areSame( output, editor.getData() );
+				}, 500 );	
+			},
+			
+		} ) );
+} )();
+	</script>
+</head>
+<body>
+<textarea id='input_1'>
+	Paragraph 1<br />
+	Paragraph 2<br />
+	Paragraph 3<br />
+</textarea>
+<textarea id='input_2'>
+	<div dir="rtl">paragraph 1<br /> 
+					paragraph 2<br /> 
+					paragraph 3</div>
+</textarea>
+</body>
+</html>
