visionmedia/mocha — pull request #780 by pwnall (2013-03-19 13:33:42+00:00)
Title: Web Workers support

The environment in Web Workers is slightly different from the standard browser environment. `document` is not defined, the global object is `self` not `window`, and some extra APIs are available, such as `FileReaderSync`. Given these differences, it is desirable to be able to run test suites in a Web Worker environment.

This change makes mocha work in Web Workers. Most of it is changing `window` references in `support/tail.js`. I added a `PostMessage` reporter that relays test results to the worker's "master" via `postMessage`, using the same format as the JSON reporter.

I also added a test for Web Workers to the `browser/index.html` suite. Unfortunately, this makes it fail when opened as a regular file in Chrome. This can be worked around by opening it from a http server in Chrome, or by running the browser tests in Firefox.

I hope that you will consider including this change, and I'll be happy to make any changes based on your feedback.