Index: /CKEditor/tests/tt/4067/1.html
===================================================================
--- /CKEditor/tests/tt/4067/1.html	(revision 4411)
+++ /CKEditor/tests/tt/4067/1.html	(revision 4411)
@@ -0,0 +1,62 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>Test #4067 - HtmlParser </title>
+	<meta name="tags" content="editor,unit,all">
+	<script type="text/javascript" src="../../cktester/cell.js"></script>
+	<script type="text/javascript">
+	//<![CDATA[
+CKEDITOR.test.runner.defer = true;
+CKEDITOR.plugins.load( 'htmlwriter' , function()
+{
+ CKEDITOR.test.runner.run();
+} );
+
+var tc;
+CKEDITOR.test.addTestCase( tc = ( function()
+{
+	// Local reference to the "assert" object.
+	var assert = CKEDITOR.test.assert;
+	function getTextareaContent( id )
+	{
+		return CKEDITOR.test.fixHtml( CKEDITOR.document.getById( id ).getValue(), false, false );
+	}
+
+	/**
+	 * Wrapper of the combination of htmlParser with htmlWriter, for convenience of
+	 * testing, formatting of writer has been disabled.
+	 */
+	function htmlParse( htmlString , writerConfig)
+	{
+		var writer = new CKEDITOR.htmlParser.basicWriter();
+		writer.reset();
+		var fragment = CKEDITOR.htmlParser.fragment.fromHtml( htmlString );
+		fragment.writeHtml( writer );
+		return writer.getHtml();
+	}
+
+	return {
+
+		// Test parsing full html document with docType declaration.
+		test_parse_fullpage_doctype : function ()
+		{
+			var inputs = [ 'html-fullpage-quirks', 'html-fullpage-html4', 'html-fullpage-xhtml' ];
+			for ( var i = 0; i < inputs.length; i++ )
+			{
+				assert.areSame( getTextareaContent( inputs[ i ] ),
+					htmlParse( getTextareaContent( inputs[ i ] ) ),
+					'Output doesn\'t match.' );
+			}
+		},
+
+		name :document.title
+	};
+} )() );
+	//]]>
+	</script>
+</head>
+<body>
+<textarea id="html-fullpage-quirks"><html dir="rtl"><head><title>My Test</title><script></script><style></style></head><body class="Test">This is some <strong>sample text</strong>.</body></html></textarea>
+<textarea id="html-fullpage-html4"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title></title></head><body></body></html></textarea>
+<textarea id="html-fullpage-xhtml"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title></title></head><body></body></html></textarea></body>
+</html>
Index: /CKEditor/tests/tt/4067/2.html
===================================================================
--- /CKEditor/tests/tt/4067/2.html	(revision 4411)
+++ /CKEditor/tests/tt/4067/2.html	(revision 4411)
@@ -0,0 +1,250 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+	"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<title>Ticket: #4067 - HtmlDataProcessor </title>
+	<meta name="tags" content="editor,unit,stable">
+	<script type="text/javascript" src="../../cktester/cell.js"></script>
+	<script>
+( function()
+{
+	var ts1, ts2, tc1, tc2, assert = CKEDITOR.test.assert;
+	function getFixedContent( id )
+	{
+		return CKEDITOR.test.fixHtml( CKEDITOR.document.getById( id ).getValue(), true, false )
+				.replace( /\s*cke_docType=".*?"/g, '' );
+	}
+
+	function getFixedValue( str )
+	{
+		return CKEDITOR.test.fixHtml( str, true, false )
+				.replace( /\s*cke_docType=".*?"/g, '' );
+	}
+
+	YAHOO.tool.TestRunner.add( ts1 = new CKEDITOR.test.suites.editorTestSuite(
+		{
+				editorName : 'test_editor_1',
+				name :document.title,
+				config :
+				{
+					docType : '',
+					fullPage : false
+				}
+		} ) );
+
+	YAHOO.tool.TestRunner.add( ts2 = new CKEDITOR.test.suites.editorTestSuite(
+		{
+				editorName : 'test_editor_2',
+				name : document.title,
+				config :
+				{
+					docType : '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
+					fullPage : true
+				}
+		} ) );
+
+	ts1.add( tc1 = new YAHOO.tool.TestCase(
+		{
+			/**
+			 * Test "toHtml", when input is a complete document just missing docType.
+			 */
+			test_htmldataprocessor_toHtml_fullPage_missing_docType : function()
+			{
+				var editor = ts1.editor,
+					dataprocessor = editor.dataProcessor,
+					input = getFixedContent( 'html-fullpage-quirks' ),
+					output = input;
+
+				// Remove editor default styles.
+				editor.config.contentsCss = [];
+				editor._.styles = [];
+				editor.config.contentsLangDirection = null;
+
+				assert.areEqual( output, dataprocessor.toHtml( input, false, true )  );
+			},
+
+			/**
+			 * Test "toHtml", when input is a document which missing <html> and docType.
+			 */
+			test_htmldataprocessor_toHtml_fullpage_missing_html : function()
+			{
+				var editor = ts1.editor,
+					dataprocessor = editor.dataProcessor,
+					input = getFixedContent( 'html-fullpage-missing-html' ),
+					output = getFixedContent( 'html-fullpage-output' );
+
+				// Remove editor default styles.
+				editor.config.contentsCss = [];
+				editor._.styles = [];
+				editor.config.contentsLangDirection = null;
+
+				assert.areEqual( output, dataprocessor.toHtml( input, false, true )  );
+			},
+
+			/**
+			 * Test "toHtml", when input is a document which missing <html>, <body> and docType.
+			 */
+			test_htmldataprocessor_toHtml_fullpage_missing_body : function()
+			{
+				var editor = ts1.editor,
+					dataprocessor = editor.dataProcessor,
+					input = getFixedContent( 'html-missing-body' ),
+					output = getFixedContent( 'html-fullpage-output' );
+
+				// Remove editor default styles.
+				editor.config.contentsCss = [];
+				editor._.styles = [];
+				editor.config.contentsLangDirection = null;
+
+				assert.areEqual( output, dataprocessor.toHtml( input, false, true )  );
+			},
+
+			/**
+			 * Test "toHtml", when input is a document which missing <head>, <html> and docType.
+			 */
+			test_htmldataprocessor_toHtml_fullpage_missing_head : function()
+			{
+				var editor = ts1.editor,
+					dataprocessor = editor.dataProcessor,
+					input = getFixedContent( 'html-fullpage-missing-head' ),
+					output = getFixedContent( 'html-fullpage-output2' );
+
+				// Remove editor default styles.
+				editor.config.contentsCss = [];
+				editor._.styles = [];
+				editor.config.contentsLangDirection = null;
+				
+				assert.areEqual( output, dataprocessor.toHtml( input, false, true )  );
+			},
+
+			/**
+			 * Test "toHtml", when input is a empty.
+			 */
+			test_htmldataprocessor_toHtml_fullpage_input_empty : function()
+			{
+				var editor = ts1.editor,
+					dataprocessor = editor.dataProcessor,
+					input = '',
+					output = getFixedContent( 'html-fullpage-output3' );
+
+				// Remove editor default styles.
+				editor.config.contentsCss = [];
+				editor._.styles = [];
+				editor.config.contentsLangDirection = null;
+
+				assert.areEqual( output, dataprocessor.toHtml( input, false, true )  );
+			},
+
+
+			/**
+			 * Test "toHtml", where 'snippet' mode is used.
+			 */
+			test_htmldataprocessor_toHtml_snippet : function()
+			{
+				var editor = ts1.editor,
+					dataprocessor = editor.dataProcessor,
+					input = getFixedContent( 'html-missing-body' ),
+					output = input;
+
+				assert.areEqual( output, dataprocessor.toHtml( input ) );
+			},
+
+			/**
+			 * Test 'toDataFormat' when 'config.fullPage' is turned off.
+			 */
+			test_htmldataprocessor_toDataFormat_fullpage_off : function()
+			{
+				var editor = ts1.editor,
+					dataprocessor = editor.dataProcessor,
+					input = getFixedContent( 'html-fullpage-xhtml' ),
+					output = getFixedContent( 'html-missing-body' );
+
+				assert.areEqual( output, dataprocessor.toDataFormat( input )  );
+			},
+			name : document.title + '1'
+		} ) );
+
+	ts2.add( tc2 = new YAHOO.tool.TestCase(
+		{
+			/**
+			 * Test "toHtml" with 'config.docType' explicitly defined.
+			 */
+			test_htmldataprocessor_toHtml_fullpage_autoDocType : function()
+			{
+				var editor = ts2.editor,
+					dataprocessor = editor.dataProcessor,
+					input = getFixedContent( 'html-fullpage-quirks' ),
+					output = getFixedContent( 'html-fullpage-xhtml' );
+
+				// Remove editor default styles.
+				editor.config.contentsCss = [];
+				editor._.styles = [];
+				editor.config.contentsLangDirection = null;
+
+				assert.areEqual( output, getFixedValue( dataprocessor.toHtml( input, false, true ) )  );
+			},
+
+			/**
+			 * Test "toHtml" when input data is empty with 'config.docType' explicitly defined.
+			 */
+			test_htmldataprocessor_toHtml_fullPage_input_empty_auto_docType : function()
+			{
+				var editor = ts2.editor,
+					dataprocessor = editor.dataProcessor,
+					input = '',
+					output = getFixedContent( 'html-fullpage-output4' );
+
+				// Remove editor default styles.
+				editor.config.contentsCss = [];
+				editor._.styles = [];
+				editor.config.contentsLangDirection = null;
+
+				assert.areEqual( output, getFixedValue( dataprocessor.toHtml( input, false, true ) ) );
+			},
+
+			/**
+			 * Test "toHtml", where 'snippet' mode is used.
+			 */
+			test_htmldataprocessor_toHtml_snippet : function()
+			{
+				var editor = ts2.editor,
+					dataprocessor = editor.dataProcessor,
+					input = getFixedContent( 'html-missing-body' ),
+					output = input;
+
+				assert.areEqual( output, getFixedValue( dataprocessor.toHtml( input ) ) );
+			},
+
+			/**
+			 * Test 'toDataFormat' when input is a complete document, and 'config.fullPage' is set to XHTML.
+			 */
+			test_htmldataprocessor_toDataFormat_fullpage_on : function()
+			{
+				var editor = ts2.editor,
+					dataprocessor = editor.dataProcessor,
+					input = getFixedContent( 'html-fullpage-xhtml' ),
+					output = input;
+
+				dataprocessor.writer._.rules = {};
+				assert.areEqual( output, getFixedValue( dataprocessor.toDataFormat( input ) ) );
+			},
+
+			name : document.title + '2'
+		} ) );
+} )();
+	</script>
+</head>
+<body>
+<textarea id="html-fullpage-quirks"><html><head><title>My Test</title><style></style></head><body class="Test">This is some <strong>sample text</strong>.</body></html></textarea>
+<textarea id="html-fullpage-xhtml"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>My Test</title><style></style></head><body class="Test">This is some <strong>sample text</strong>.</body></html></textarea></body>
+<textarea id="html-fullpage-missing-html"><body>This is some <strong>sample text</strong>.</body></textarea>
+<textarea id="html-missing-body">This is some <strong>sample text</strong>.</textarea>
+
+<textarea id="html-fullpage-output"><html><head><title></title></head><body>This is some <strong>sample text</strong>.</body></html></textarea>
+<textarea id="html-fullpage-output2"><html><head><title>My Test</title><style></style></head><body></body></html></textarea>
+<textarea id="html-fullpage-output3"><html><head><title></title></head><body></body></html></textarea>
+<textarea id="html-fullpage-output4"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title></head><body></body></html></textarea>
+
+<textarea id="html-fullpage-missing-head"><title>My Test</title><style></style></textarea>
+</body>
+</html>
Index: /CKEditor/tests/tt/4067/3.html
===================================================================
--- /CKEditor/tests/tt/4067/3.html	(revision 4411)
+++ /CKEditor/tests/tt/4067/3.html	(revision 4411)
@@ -0,0 +1,120 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+	"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<title>Ticket: #4067 - Editor Output Data</title>
+	<meta name="tags" content="editor,unit,stable">
+	<script type="text/javascript" src="../../cktester/cell.js"></script>
+	<script>
+( function()
+{
+	var ts, tc, assert = CKEDITOR.test.assert;
+
+	function getFixedContent( id )
+	{
+		return CKEDITOR.test.fixHtml( CKEDITOR.document.getById( id ).getValue(), false, false )
+				.replace( /\s*cke_docType=".*?"/g, '' );
+	}
+
+	function getFixedValue( str )
+	{
+		return CKEDITOR.test.fixHtml( str, false, false )
+				.replace( /\s*cke_docType=".*?"/g, '' );
+	}
+
+	YAHOO.tool.TestRunner.add( ts = new CKEDITOR.test.suites.editorTestSuite(
+		{
+				editorName : 'test_editor_1',
+				name : document.title,
+				startupData : '<html><head></head><body><p>some<strong>text</strong>.</p></body></html>',
+				config :
+				{
+					docType : '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
+					contentsLangDirection : 'ltr',
+					fullPage : true,
+					contentsCss : []
+				}
+		} ) );
+
+	ts.add( tc = new YAHOO.tool.TestCase(
+		{
+
+			// Test 'getData' with fullPage support and XHTML doctype explicitly defined.
+			test_editor_getData : function ()
+			{
+				var editor = ts.editor,
+					output = getFixedContent( 'editor-data-output' );
+
+				assert.areEqual( output, getFixedValue( editor.getData() ) );
+			},
+
+
+			// Test 'getData' with fullPage support and XHTML doctype explicitly defined.
+			test_editor_getData_2 : function ()
+			{
+				var editor = ts.editor,
+					output = getFixedContent( 'editor-data-output2' );
+
+				// Remove editor default styles.
+				editor.config.contentsCss = [];
+				editor._.styles = [];
+				editor.config.contentsLangDirection = null;
+
+				editor.setData( getFixedContent( 'editor-data-input2' ), function(){
+					tc.resume( function()
+					{
+						assert.areEqual( output, getFixedValue( editor.getData() ) );
+					} );
+				} );
+				tc.wait();
+			},
+
+			name : document.title
+		} ) );
+} )();
+	</script>
+</head>
+<body>
+
+<textarea id="test_editor_1">
+</textarea>
+
+<textarea id="editor-data-output">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<title>
+		</title>
+	</head>
+	<body>
+		<p>
+			some<strong>text</strong>.</p>
+	</body>
+</html>
+</textarea>
+
+<textarea id="editor-data-input2">
+<html dir="ltr">
+<head>
+	<meta content="wysiwyg,editor,javascript" name="keywords"/>
+</head>
+<body>
+	<p>	This is some <strong>sample text</strong>.</p>
+</body>
+</html>
+</textarea>
+<textarea id="editor-data-output2"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<title>
+		</title>
+		<meta content="wysiwyg,editor,javascript" name="keywords"/>
+	</head>
+	<body>
+		<p>
+			This is some <strong>sample text</strong>.</p>
+	</body>
+</html>
+</textarea>
+</body>
+</html>
