Skip to content

Commit

Permalink
Have global exports be compatible with Web Workers
Browse files Browse the repository at this point in the history
Assigning to `window` only works in a normal browser environment;
however, Web Workers don't have access to `window`. Instead, the global
object inside Web Workers is `self`.

Browserify ensures that `global` is present to all scripts by creating a
shim reference to it using this logic:

    typeof global !== "undefined" ? global :
    typeof self !== "undefined" ? self :
    typeof window !== "undefined" ? window : {}

Thus, if neither `global` nor `self` were originally present,
`global === window` will be true.

Web Workers compatibility was broken in a81e555.
  • Loading branch information
mislav committed Jan 15, 2016
1 parent 65e2984 commit 95d7d5b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions support/browser-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,5 @@ Mocha.process = process;
* Expose mocha.
*/

window.Mocha = Mocha;
window.mocha = mocha;
global.Mocha = Mocha;
global.mocha = mocha;

0 comments on commit 95d7d5b

Please sign in to comment.