Skip to content

Commit 95d7d5b

Browse files
committed
Have global exports be compatible with Web Workers
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.
1 parent 65e2984 commit 95d7d5b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

support/browser-entry.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,5 @@ Mocha.process = process;
157157
* Expose mocha.
158158
*/
159159

160-
window.Mocha = Mocha;
161-
window.mocha = mocha;
160+
global.Mocha = Mocha;
161+
global.mocha = mocha;

0 commit comments

Comments
 (0)