如何测试(automatedly)该浏览器重绘后发生的操作? [英] How to test (automatedly) that an operation occurs after browser repaint?
问题描述
根据这篇博客的意见,以下技术的执行操作异步但对于一个重绘等待:
According to the comments of this blog post, the following technique executes an operation asynchronously but waits for a repaint:
function nextTick(callback) {
var img = new Image;
img.onerror = callback;
img.src = 'data:image/png,' + Math.random();
}
而这一个不等待重绘:
whereas this one does not wait for a repaint:
var mc = new MessageChannel;
function nextTick(callback) {
mc.port1.onmessage = callback;
mc.port2.postMessage(0);
}
我怎么能验证这一点,编程,在多个平台上运行的自动化测试的方式/浏览器可以检查?
How could I verify this, programmatically, in a way that automated tests running on multiple platforms/browsers could check?
推荐答案
您可能希望在博客中使用 requestAnimationFrame
,而不是解决办法的。
You may want to use requestAnimationFrame
instead of the workaround in the blog post.
了解更多关于它在保罗爱尔兰的博客 http://paulirish.com/2011 / requestanimationframe换智能动画/
Read more about it at Paul Irish's blog http://paulirish.com/2011/requestanimationframe-for-smart-animating/
这篇关于如何测试(automatedly)该浏览器重绘后发生的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!