☕️ Classic, reliable, trusted test framework for Node.js and the browser
Re-implemented setZeroTimeout.
Guillermo Rauch1cbba42300ce
diff --git a/support/tail.js b/support/tail.jsindex c5861ca9..60970bae 100644--- a/support/tail.js+++ b/support/tail.js@@ -13,7 +13,28 @@ process.exit = function(status){};process.stdout = {};global = window;-process.nextTick = setZeroTimeout;+process.nextTick = (function(){+ if (window.ActiveXObject || !window.postMessage) {+ // postMessage behaves badly on IE8+ return function(fn){ fn() };+ } else {+ // based on setZeroTimeout by David Baron+ // - http://dbaron.org/log/20100309-faster-timeouts+ var timeouts = []+ , name = 'mocha-zero-timeout'++ return function(fn){+ timeouts.push(fn);+ window.postMessage(name, '*');+ window.addEventListener('message', function(event){+ if (event.source == window && event.data == name) {+ if (event.stopPropagation) event.stopPropagation();+ if (timeouts.length) timeouts.shift()();+ }+ }, true);+ }+ }+})();process.removeListener = function(ev){if ('uncaughtException' == ev) {