Page: Attach unit test delegated handler to document instead

Closes gh-7235
Fixes gh-7234

(cherry picked from commit 0d5d6c21f47b7310e63f5b7ebeba8169a2ce0cdb)