Implement page lifecycle events (Phase 17)
Add DOMContentLoaded, load, beforeunload, pagehide, and unload events
with correct firing order. Implement document.readyState property
with loading → interactive → complete transitions.
- DOMContentLoaded fires on document after sync scripts, bubbles to window
- load fires on window after all resources (CSS, fonts, images) are loaded
- beforeunload fires before navigation and can cancel via preventDefault()
- pagehide and unload fire during document teardown
- VM persisted in PageState so lifecycle handlers survive page load
- Window object gets sentinel __node_id__ for addEventListener support
- 10 new unit tests covering event ordering, readyState transitions,
and beforeunload cancellation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>