Support testing in a service worker

These changes allow Promise based tests to be performed in Service Workers (https://slightlyoff.github.io/ServiceWorker/spec/service_worker/). Some example tests can be found in (https://github.com/asankah/web-platform-tests/tree/service-workers/service-workers/resources). I hope that the breakdown of the individual commits make it easier to review. The commit messages describe what each commit is doing.

ServiceWorkers introduce a substantial API surface that is only visible from within the worker. Hence it's quite convenient to be able to invoke `testharness.js` from within the worker rather than hand-rolling separate `assert_*()` functions or splitting the test logic between a client document and a worker.