Index: /CKEditor/branches/versions/3.2.x/_source/core/tools.js
===================================================================
--- /CKEditor/branches/versions/3.2.x/_source/core/tools.js	(revision 5158)
+++ /CKEditor/branches/versions/3.2.x/_source/core/tools.js	(revision 5159)
@@ -620,4 +620,14 @@
 
 		/**
+		 * Removes the function reference created with {@see CKEDITOR.tools.addFunction}.
+		 * @param {Number} ref The function reference created with
+		 *		CKEDITOR.tools.addFunction.
+		 */
+		removeFunction : function( ref )
+		{
+			functions[ ref ] = null;
+		},
+
+		/**
 		 * Executes a function based on the reference created with
 		 * CKEDITOR.tools.addFunction.
Index: /CKEditor/branches/versions/3.2.x/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.2.x/_source/plugins/wysiwygarea/plugin.js	(revision 5158)
+++ /CKEditor/branches/versions/3.2.x/_source/plugins/wysiwygarea/plugin.js	(revision 5159)
@@ -264,34 +264,44 @@
 
 						frameLoaded = 0;
+						
+						var setDataFn = !CKEDITOR.env.gecko && CKEDITOR.tools.addFunction( function( doc )
+							{
+								CKEDITOR.tools.removeFunction( setDataFn );
+								doc.write( data );
+							});
+
+						var srcScript =
+							'document.open();' +
+
+							// The document domain must be set any time we
+							// call document.open().
+							( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +
+
+							// With FF, it's better to load the data on
+							// iframe.load. (#3894,#4058)
+							// But in FF, we still need the open()-close() call
+							// to avoid HTTPS warnings.
+							( CKEDITOR.env.gecko ? '' : ( 'parent.CKEDITOR.tools.callFunction(' + setDataFn + ',document);' ) ) +
+
+							'document.close();';
 
 						iframe = CKEDITOR.dom.element.createFromHtml( '<iframe' +
   							' style="width:100%;height:100%"' +
   							' frameBorder="0"' +
-							( !CKEDITOR.env.webkit ?
-								// Support for custom document.domain in IE.
-								' src="javascript:void((function(){' +
-								'document.open();' +		// To avoid HTTPS warnings.
-								( isCustomDomain ?
-									'document.domain=\'' + document.domain + '\';' : '' ) +
-								'document.close();' +
-								'})())"' : '' ) +
+  							' src="javascript:void(function(){' + encodeURIComponent( srcScript ) + '}())"' +
   							' tabIndex="' + editor.tabIndex + '"' +
   							' allowTransparency="true"' +
   							'></iframe>' );
 
-						// Register onLoad event for iframe element, which
-						// will fill it with content and set custom domain.
-						iframe.on( 'load', function( e )
-							{
-								e.removeListener();
+						// With FF, it's better to load the data on iframe.load. (#3894,#4058)
+						CKEDITOR.env.gecko && iframe.on( 'load', function( ev )
+							{
+								ev.removeListener();
+
 								var doc = iframe.getFrameDocument().$;
 
-								// Custom domain handling is needed after each document.open().
 								doc.open();
-								if ( isCustomDomain )
-									doc.domain = document.domain;
 								doc.write( data );
 								doc.close();
-
 							});
 
@@ -311,5 +321,6 @@
 					var activationScript =
 						'<script id="cke_actscrpt" type="text/javascript" cke_temp="1">' +
-							'window.parent.CKEDITOR._["contentDomReady' + editor.name + '"]( window );' +
+							( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +
+							'parent.CKEDITOR._["contentDomReady' + editor.name + '"]( window );' +
 						'</script>';
 
