﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
16676	Improvements in loading the debug code for async	Robert Flaherty		"== Steps to reproduce ==

1. Add async=""async"" into the script tag for ckeditor.js.
2. Launch the HTML in FF.
3. It may take a few launches, with or without clearing the cache, but look for a console error.

== Expected result ==
Script would load normally.

== Actual result ==
""A call to document.write() from an asynchronously-loaded external script was ignored."" in the console.

== Other details (browser, OS, CKEditor version, installed plugins) ==
FF50, Win7, 4.5.11, many plugins.

I've been running into issues with the debug code being used with RequireJS.  This use case is a simplified example of the first issues I hit.

This may be moot with the 5.x line and the AMD branch, but for 4.x, a few tweaks can be added.  I altered the debug ckeditor.js and core/loader.js and added to the test:

if ( document.body && ( !document.readyState | | document.readyState == 'complete' | | document.readyState == 'interactive' | | (document.currentScript && document.currentScript.async) ) )

Per the web, ""interactive"" does still mean the doc is loaded and parsed, while still waiting on images/script/frames, so adding a script node sounds legal.

For the currentScript.async test, if this script was loaded with async, writing to the doc should never be allowed.  This flag didn't seem to pickup if a script calling this script was async, so its' not perfect.

Additionally, I wasn't sure if there was a benefit to doing ""document.getElementsByTagName(""head"")[0].appendChild(script)"" instead of ""document.body.appendChild(script)"".

"	New Feature	confirmed	Normal		General	4.0			
