Implement document load tracking.

Improves on the state of the art for #1416. Images, XHR, stylesheets, and scripts now block the document load event from firing, and DOMContentLoaded is dispatched after parsing is complete.
We have no speculative parsing yet, and no JS event loop spinning occurs. Asynchronous networking will come after #4057; currently we aren't able to easily send messages to the script event queue that interact with arbitrary DOM objects, so synchronous networking has traditionally been required.