Index: /CKEditor/tests/tt/4340/1.html
===================================================================
--- /CKEditor/tests/tt/4340/1.html	(revision 4536)
+++ /CKEditor/tests/tt/4340/1.html	(revision 4537)
@@ -4,25 +4,19 @@
 <head>
 	<title>Ticket: #4340 - Encoding Protection</title>
-	<meta name="tags" content="editor,unit,stable">
+	<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;
-	function getFixedContent( id )
+	var ts, tc, test = CKEDITOR.test, assert = CKEDITOR.test.assert;
+	function getTextAreaContent( 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, '' );
+		return CKEDITOR.test.fixHtml( CKEDITOR.document.getById( id ).getValue(), true, false );
 	}
 
 	YAHOO.tool.TestRunner.add( ts = new CKEDITOR.test.suites.editorTestSuite(
 		{
-				editorName : 'test_editor_1',
+				editorName : 'editor1',
+				startupData : '',
 				name :document.title,
 				config :
@@ -35,41 +29,75 @@
 	ts.add( tc = new YAHOO.tool.TestCase(
 		{
-			/**
-			 * Test email href attribute are well protected into a function.
-			 */
-			test_htmldataprocessor_toDataFormat_protectEmail : function()
+			setUp : function ()
 			{
-				var editor = ts.editor,
-					dataprocessor = editor.dataProcessor,
-					input = '<a _cke_saved_href="mailto:tester@ckeditor.com?subject=subject&body=body">e-mail</a>',
-					output = '<a href=\"javascript:void(location.href=\'mailto:\'+String.fromCharCode(116,101,115,116,101,114,64,99,107,101,100,105,116,111,114,46,99,111,109)+\'?subject=subject&body=body\')\">e-mail</a>';
-
-				assert.areEqual( output, dataprocessor.toDataFormat( input, false )  );
+				// Force result data unformatted.
+				ts.editor.dataProcessor.writer._.rules = {};
+				ts.editor.focus();
 			},
 
 			/**
-			 * Test protected email function in href attribute are well restored.
+			 * Test email address attribute are well protected into encoded chars.
 			 */
-			test_htmldataprocessor_toHtml_unProtectEmail : function()
+			test_protectEmailLink : function()
 			{
 				var editor = ts.editor,
-					dataprocessor = editor.dataProcessor,
-					output = '<a href="mailto:tester@ckeditor.com?subject=subject&amp;body=body" _cke_saved_href="mailto:tester@ckeditor.com?subject=subject&amp;body=body">e-mail</a>',
-					input = '<a href=\"javascript:void(location.href=\'mailto:\'+String.fromCharCode(116,101,115,116,101,114,64,99,107,101,100,105,116,111,114,46,99,111,109)+\'?subject=subject&body=body\')\">e-mail</a>';
+					command = 'link';
 
-				assert.areEqual( output, dataprocessor.toHtml( input, false )  );
+				test.setHtmlWithSelection( editor.document.getBody(), '<a href="#">[AJD]</a>' );
+
+				editor.execCommand( command );
+
+				// waiting for dialog to open.
+				this.wait( function()
+				{
+					 var dialog = editor._.storedDialogs[ command ],
+						 linkTypeField = dialog.getContentElement( 'info', 'linkType' ),
+						 addressField = dialog.getContentElement( 'info', 'emailAddress' ),
+						 subjectField = dialog.getContentElement( 'info', 'emailSubject' ),
+						 bodyField = dialog.getContentElement( 'info', 'emailBody' );
+
+					linkTypeField.setValue( 'email' );
+					addressField.setValue( 'job@cksource.com' );
+					subjectField.setValue( 'Job Request' );
+					bodyField.setValue( 'I\'m looking for the AJD position.' );
+					dialog.fire( 'ok' );
+					dialog.hide();
+
+					var result = editor.getData();
+					assert.areEqual( getTextAreaContent( 'email-protection-output' ), result, 'Inserted e-mail href doesn\'t match.' );
+
+				}, 1000 );
 			},
 
 			/**
-			 * Test protected email function works as a whole.
+			 * Test 'Link' dialog read from 'encode' protected email address link.
 			 */
-			test_htmldataprocessor_toHtml_toDataFormat : function()
+			test_readFromProtectedEmailLink : function ()
 			{
 				var editor = ts.editor,
-					dataprocessor = editor.dataProcessor,
-					input = '<a _cke_saved_href="mailto:tester@ckeditor.com?body=body&subject=subject">e-mail</a>',
-					result = '<a href="mailto:tester@ckeditor.com?body=body&amp;subject=subject" _cke_saved_href="mailto:tester@ckeditor.com?body=body&amp;subject=subject">e-mail</a>';
-				assert.areEqual( result, dataprocessor.toHtml( dataprocessor.toDataFormat( input, false ), false )  );
+					command = 'link';
+
+				editor.execCommand( command );
+
+				// waiting for dialog to open.
+				this.wait( function()
+				{
+					 var dialog = editor._.storedDialogs[ command ],
+						 linkTypeField = dialog.getContentElement( 'info', 'linkType' ),
+						 addressField = dialog.getContentElement( 'info', 'emailAddress' ),
+						 subjectField = dialog.getContentElement( 'info', 'emailSubject' ),
+						 bodyField = dialog.getContentElement( 'info', 'emailBody' );
+
+					assert.areEqual( 'email', linkTypeField.getValue() );
+					assert.areEqual( 'job@cksource.com', addressField.getValue() );
+					assert.areEqual( 'Job Request', subjectField.getValue() );
+					assert.areEqual( 'I\'m looking for the AJD position.', bodyField.getValue() );
+
+					dialog.fire( 'ok' );
+					dialog.hide();
+
+				}, 1000 );
 			}
+
 		} ) );
 } )();
@@ -77,4 +105,7 @@
 </head>
 <body>
+<textarea id="email-protection-output">
+<p><a href="javascript:void(location.href='mailto:'+String.fromCharCode(106,111,98,64,99,107,115,111,117,114,99,101,46,99,111,109)+'?subject=Job%20Request&body=I\'m%20looking%20for%20the%20AJD%20position.')">AJD</a></p>
+</textarea>
 </body>
 </html>
Index: Editor/tests/tt/4340/2.html
===================================================================
--- /CKEditor/tests/tt/4340/2.html	(revision 4536)
+++ 	(revision )
@@ -1,80 +1,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-	"http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-	<title>Ticket: #4340 - Function Protection </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(), 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( ts = new CKEDITOR.test.suites.editorTestSuite(
-		{
-				editorName : 'test_editor_1',
-				name :document.title,
-				config :
-				{
-					mailProtection : 'mt(BODY,SUBJECT,NAME,DOMAIN)'
-				}
-		} ) );
-
-	ts.add( tc = new YAHOO.tool.TestCase(
-		{
-			/**
-			 * Test email href attribute are well protected into a function.
-			 */
-			test_htmldataprocessor_toDataFormat_protectEmail : function()
-			{
-				var editor = ts.editor,
-					dataprocessor = editor.dataProcessor,
-					input = '<a _cke_saved_href="mailto:tester@ckeditor.com?subject=subject&body=body">e-mail</a>',
-					output = '<a href="javascript:mt(\'body\',\'subject\',\'tester\',\'ckeditor.com\')">e-mail</a>';
-
-				assert.areEqual( output, dataprocessor.toDataFormat( input, false )  );
-			},
-
-			/**
-			 * Test protected email function in href attribute are well restored.
-			 */
-			test_htmldataprocessor_toHtml_unProtectEmail : function()
-			{
-				var editor = ts.editor,
-					dataprocessor = editor.dataProcessor,
-					output = '<a href="mailto:tester@ckeditor.com?body=body\'text&subject=subject" _cke_saved_href="mailto:tester@ckeditor.com?body=body\'text&subject=subject">e-mail</a>',
-					input = '<a href="javascript:mt(\'body\\\'text\',\'subject\',\'tester\',\'ckeditor.com\')">e-mail</a>';
-
-				assert.areEqual( output, dataprocessor.toHtml( input, false )  );
-			},
-
-			/**
-			 * Test protected email function works as a whole.
-			 */
-			test_htmldataprocessor_toHtml_toDataFormat : function()
-			{
-				var editor = ts.editor,
-					dataprocessor = editor.dataProcessor,
-					input = '<a _cke_saved_href="mailto:tester@ckeditor.com?body=body&subject=subject">e-mail</a>',
-					result = '<a href="mailto:tester@ckeditor.com?body=body&subject=subject" _cke_saved_href="mailto:tester@ckeditor.com?body=body&subject=subject">e-mail</a>';
-				editor.config.mailProtection = 'mt(NAME,DOMAIN,BODY,SUBJECT)';
-				assert.areEqual( result, dataprocessor.toHtml( dataprocessor.toDataFormat( input, false ), false )  );
-			}
-		} ) );
-} )();
-	</script>
-</head>
-<body>
-</body>
-</html>
