mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
Make setZeroTimeout use window.setTimeout
This commit is contained in:
parent
cb2f83cf8e
commit
6089e45b7d
21 changed files with 335 additions and 98 deletions
40
tests/wpt/webgl/tools/set-zero-timeout.patch
Normal file
40
tests/wpt/webgl/tools/set-zero-timeout.patch
Normal file
|
@ -0,0 +1,40 @@
|
|||
--- 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.
|
Loading…
Add table
Add a link
Reference in a new issue