diff --git a/src/core/ClearStack.js b/src/core/ClearStack.js index a9f645ed..29ec3688 100644 --- a/src/core/ClearStack.js +++ b/src/core/ClearStack.js @@ -41,6 +41,18 @@ getJasmineRequireObj().clearStack = function(j$) { }; } + function getUnclampedSetTimeout(global) { + const { setTimeout } = global; + if (j$.util.isUndefined(global.MessageChannel)) return setTimeout; + + const postMessage = getPostMessage(global); + return function unclampedSetTimeout(fn) { + postMessage(function() { + setTimeout(fn); + }); + }; + } + function getPostMessage(global) { const { MessageChannel, setTimeout } = global; const channel = new MessageChannel();