Index: /CKEditor/tests/tt/4340/2.html
===================================================================
--- /CKEditor/tests/tt/4340/2.html	(revision 4538)
+++ /CKEditor/tests/tt/4340/2.html	(revision 4538)
@@ -0,0 +1,109 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+	"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<title>Ticket: #4340 - Function Call Protection</title>
+	<meta name="tags" content="editor,unit,all">
+	<script type="text/javascript" src="../../cktester/cell.js"></script>
+	<script>
+( function()
+{
+	var ts, tc, test = CKEDITOR.test, assert = CKEDITOR.test.assert;
+	function getTextAreaContent( id )
+	{
+		return CKEDITOR.test.fixHtml( CKEDITOR.document.getById( id ).getValue(), true, false );
+	}
+
+	YAHOO.tool.TestRunner.add( ts = new CKEDITOR.test.suites.editorTestSuite(
+		{
+				editorName : 'editor1',
+				startupData : '',
+				name :document.title,
+				config :
+				{
+					forceSimpleAmpersand : true,
+					mailProtection : 'mt(BODY,SUBJECT,NAME,DOMAIN)'
+				}
+		} ) );
+
+	ts.add( tc = new YAHOO.tool.TestCase(
+		{
+			setUp : function ()
+			{
+				// Force result data unformatted.
+				ts.editor.dataProcessor.writer._.rules = {};
+				ts.editor.focus();
+			},
+
+			/**
+			 * Test email address attribute are well protected into function call.
+			 */
+			test_protectEmailLink : function()
+			{
+				var editor = ts.editor,
+					command = 'link';
+
+				test.setHtmlWithSelection( ts.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 'Link' dialog read from 'function call' protected email address link.
+			 */
+			test_readFromProtectedEmailLink : function ()
+			{
+				var editor = ts.editor,
+					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( 'job@cksource.com', addressField.getValue() );
+					assert.areEqual( 'Job Request', subjectField.getValue() );
+					assert.areEqual( 'I\'m looking for the AJD position.', bodyField.getValue() );
+					assert.areEqual( 'email', linkTypeField.getValue() );
+
+					dialog.fire( 'ok' );
+					dialog.hide();
+
+				}, 1000 );
+			}
+		} ) );
+} )();
+	</script>
+</head>
+<body>
+<textarea id="email-protection-output">
+<p><a href="javascript:mt('I\'m%20looking%20for%20the%20AJD%20position.','Job%20Request','job','cksource.com')">AJD</a></p>
+</textarea>
+</body>
+</html>
