servo/tests/wpt/webgl/tools/set-zero-timeout.patch
2018-08-29 02:05:49 +02:00

40 lines
1.1 KiB
Diff

--- 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.