Simplify WindowTestEnvironment cross document messaging.

Reduce code duplication among the message dispatch logic for different
callbacks.
Update apisample11.html to add stricter callback verification.

For cross document cases, callbacks can initiate from the host document
as well as any child documents. The updates attempt to separate the two
sources of callbacks by explicitly avoiding any testharness calls until
the child document is done.
Cleanup for WorkerTestEnvironments.