Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Removed setZeroTimeout (fixes #161).

Guillermo Rauchfd57007a7afb
diff --git a/Makefile b/Makefile
index 93d4a91e..64fb1517 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,6 @@ mocha.js: $(SRC) $(SUPPORT)
@cat \
support/head.js \
_mocha.js \
- support/setZeroTimeout.js \
support/{tail,foot}.js \
> mocha.js
diff --git a/support/setZeroTimeout.js b/support/setZeroTimeout.js
deleted file mode 100644
index ac9384c1..00000000
--- a/support/setZeroTimeout.js
+++ /dev/null
@@ -1,41 +0,0 @@
-// Only add setZeroTimeout to the window object, and hide everything else in a closure.
-(function() {
-
- var timeouts = [],
- messageName = 'zero-timeout-message';
-
- // Like setTimeout, but only takes a function argument. There's
- // no time argument (always zero) and no arguments (you have to
- // use a closure).
- function setZeroTimeoutPostMessage(fn) {
- timeouts.push(fn);
- window.postMessage(messageName, '*');
- }
-
- function setZeroTimeout(fn) {
- setTimeout(fn, 0);
- }
-
- function handleMessage(event) {
- if (event.source == window && event.data == messageName) {
- if (event.stopPropagation) {
- event.stopPropagation();
- }
- if (timeouts.length) {
- timeouts.shift()();
- }
- }
- }
-
- if (window.postMessage) {
- if (window.addEventListener) {
- window.addEventListener('message', handleMessage, true);
- } else if (window.attachEvent) {
- window.attachEvent('onmessage', handleMessage);
- }
- window.setZeroTimeout = setZeroTimeoutPostMessage;
- } else {
- window.setZeroTimeout = setZeroTimeout;
- }
-
-}());
\ No newline at end of file