/
githubmirror
/
servo
Обзор
Документация
Войти
/
githubmirror
/
servo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/wpt/webgl/tools/set-zero-timeout.patch
40 строк
1 KB
Anthony Ramine
Make setZeroTimeout use window.setTimeout
29 авг 2018, 03:05
29 авг 2018, 03:05
6089e45
Код
Авторство
О чём код?
--- js/webgl-test-utils.js +++ js/webgl-test-utils.js @@ -2876,34 +2876,9 @@ var waitForComposite = function(callback) { countDown(); }; -var setZeroTimeout = (function() { - // See https://dbaron.org/log/20100309-faster-timeouts - - var timeouts = []; - var 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 setZeroTimeout(fn) { - timeouts.push(fn); - window.postMessage(messageName, "*"); - } - - function handleMessage(event) { - if (event.source == window && event.data == messageName) { - event.stopPropagation(); - if (timeouts.length > 0) { - var fn = timeouts.shift(); - fn(); - } - } - } - - window.addEventListener("message", handleMessage, true); - - return setZeroTimeout; -})(); +var setZeroTimeout = function(handler) { + window.setTimeout(handler, 0); +} /** * Runs an array of functions, yielding to the browser between each step.