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.
The very existence of machinery to load something synchronously worries me. If this is mean to be sync only from the Rust task point of view and never from the JS point of view, it would be good to have some comment to that effect to make this less scary.