apache/incubator-cordova-js — pull request #11 by jareware (2012-05-09 11:09:20+00:00)
Title: Async loading & document.readyState == 'interactive'

At least on Android ICS WebView, when loading cordova.js asynchronously, it's possible to end up in a situation where the "DOMContentLoaded" has already fired, but the document.readyState is not "complete" (but still "interactive"). This patches this race condition.

Technically document.readyState === "interactive" is not exactly the same as when "DOMContentLoaded" triggers, but since the document is already done parsing (ref: http://dev.w3.org/html5/spec/the-end.html) it should be perfectly fine for Cordova's intents and purposes. If you think this is too early, one could always defer onDOMContentLoaded.fire() to the subsequent "load" event if we find document.readyState == "interactive".

This may be a bit of an edge case, since the same version of Cordova (1.7.0) worked fine on Gingerbread, and most people don't load Cordova async, but this issue has been noted on other projects/browsers too (ref: http://bugs.jquery.com/ticket/10067).

Sorry for not including a test case; if you have a facility for reliably testing issues like this, let me know and I'll try to put it in.

Related: https://issues.apache.org/jira/browse/CB-499