Index: /CKEditor/tests/tt/6665/1.html
===================================================================
--- /CKEditor/tests/tt/6665/1.html	(revision 6417)
+++ /CKEditor/tests/tt/6665/1.html	(revision 6417)
@@ -0,0 +1,92 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+	"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<title>Ticket: #6665 Link dialog</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',
+				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();
+			},
+
+			test_insert_link: function()
+			{
+				var editor = ts.editor,
+				
+					contentWithSelection = test.getValueAsHtml( 'input_1' ),
+					output = '<p><a href="http://cksource.com" name="test">http://cksource.com</a></p>',
+					command = 'link';
+				
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				
+				editor.execCommand( command );
+
+				this.wait( function ()
+				{
+					
+					var dialog = editor._.storedDialogs[ command ],
+						urlField = dialog.getContentElement( 'info', 'url' ),
+						nameField = dialog.getContentElement( 'advanced', 'advName' );
+						
+					urlField.setValue( 'cksource.com' );
+					nameField.setValue( 'test' );
+					dialog.fire( 'ok' );
+					dialog.hide();
+					
+					assert.areSame( output, editor.getData() );
+					
+				}, 1000 );
+			},
+			//link edit is run on selection from link button
+			test_edit_link: function()
+			{
+				var editor = ts.editor,
+				
+					contentWithSelection = test.getValueAsHtml( 'output_1' ),
+					output = '<p><a href="http://cksource.com" name="test">http://cksource.com</a></p>',
+					command = 'link';
+				
+				test.setHtmlWithSelection( editor.document.getBody(), contentWithSelection );
+				
+				editor.execCommand( command );
+
+				this.wait( function ()
+				{
+					
+					var dialog = editor._.storedDialogs[ command ],
+						urlField = dialog.getContentElement( 'info', 'url' ),
+						nameField = dialog.getContentElement( 'advanced', 'advName' );
+					
+					//If field values were not loaded, part of link should be missing on firing 'OK'
+					dialog.fire( 'ok' );
+					dialog.hide();
+					
+					assert.areSame( output, editor.getData() );
+					
+				}, 1000 );
+			},
+		} ) );
+} )();
+	</script>
+</head>
+<body>
+<textarea id='input_1'></textarea>
+<textarea id='output_1'><p><a href="http://cksource.com" name="test">[http://cksource.com]</a></p></textarea>
+</body>
+</html>
