☕️ Classic, reliable, trusted test framework for Node.js and the browser
Only add one postMessage event listener. Fixes unresponsive browser during and after tests.
Brian Beck66b33c92f1fa
diff --git a/support/tail.js b/support/tail.jsindex e3d44727..ddc580d1 100644--- a/support/tail.js+++ b/support/tail.js@@ -27,15 +27,16 @@ process.nextTick = (function(){var timeouts = [], name = 'mocha-zero-timeout'+ window.addEventListener('message', function(e){+ if (e.source == window && e.data == name) {+ if (e.stopPropagation) e.stopPropagation();+ if (timeouts.length) timeouts.shift()();+ }+ }, true);+return function(fn){timeouts.push(fn);window.postMessage(name, '*');- window.addEventListener('message', function(e){- if (e.source == window && e.data == name) {- if (e.stopPropagation) e.stopPropagation();- if (timeouts.length) timeouts.shift()();- }- }, true);}})();