зеркало из https://github.com/mozilla/gecko-dev.git
Bug 940842 - 3/3 - Add a mochitest covering repaint heuristics with will-change - r=mattwoodrow
This commit is contained in:
Родитель
6e831dc5e6
Коммит
7d19d91f93
|
@ -48,3 +48,4 @@ support-files=scroll_selection_into_view_window.html
|
||||||
[test_transformed_scrolling_repaints.html]
|
[test_transformed_scrolling_repaints.html]
|
||||||
[test_transformed_scrolling_repaints_2.html]
|
[test_transformed_scrolling_repaints_2.html]
|
||||||
[test_transformed_scrolling_repaints_3.html]
|
[test_transformed_scrolling_repaints_3.html]
|
||||||
|
[test_will_change.html]
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Tests for MozAfterPaint</title>
|
||||||
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
|
||||||
|
<!-- This CSS must not be parsed before we get a change to set layout.css.will-change.enabled=true -->
|
||||||
|
<script type="css_but_do_not_parse" id="csscode">
|
||||||
|
#checkOpacityRepaint {
|
||||||
|
will-change: opacity;
|
||||||
|
}
|
||||||
|
#checkTransformRepaint {
|
||||||
|
will-change: transform;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
background: radial-gradient(ellipse at center, #87e0fd 0%,#53cbf1 40%,#05abe0 100%);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="checkRepaint">
|
||||||
|
Check repaint without will-change
|
||||||
|
</div>
|
||||||
|
<div id="checkOpacityRepaint">
|
||||||
|
Check repaint with will-change
|
||||||
|
</div>
|
||||||
|
<div id="checkTransformRepaint">
|
||||||
|
Check repaint with will-change
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||||
|
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||||
|
|
||||||
|
var initialPaintCount = 0;
|
||||||
|
|
||||||
|
function test_checkRepaint(next) {
|
||||||
|
var element = document.getElementById("checkRepaint");
|
||||||
|
waitForAllPaintsFlushed(function () {
|
||||||
|
utils.checkAndClearPaintedState(element);
|
||||||
|
element.style.opacity = "0.5";
|
||||||
|
waitForAllPaintsFlushed(function () {
|
||||||
|
var painted = utils.checkAndClearPaintedState(element);
|
||||||
|
// *** We check that this repaints because the test is relying
|
||||||
|
// on this property. If this is broken then this test wont
|
||||||
|
// be reliable check for will-change.
|
||||||
|
is(painted, true, "element should have been painted");
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_checkOpacityRepaint(next) {
|
||||||
|
var element = document.getElementById("checkOpacityRepaint");
|
||||||
|
waitForAllPaintsFlushed(function () {
|
||||||
|
utils.checkAndClearPaintedState(element);
|
||||||
|
element.style.opacity = "0.5";
|
||||||
|
waitForAllPaintsFlushed(function () {
|
||||||
|
var painted = utils.checkAndClearPaintedState(element);
|
||||||
|
// BasicLayers' heuristics are so that even with will-change:opacity,
|
||||||
|
// we can still have repaints.
|
||||||
|
if (utils.layerManagerType != "Basic") {
|
||||||
|
is(painted, false, "will-change checkOpacityRepaint element should not have been painted");
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_checkTransformRepaint(next) {
|
||||||
|
var element = document.getElementById("checkTransformRepaint");
|
||||||
|
waitForAllPaintsFlushed(function () {
|
||||||
|
utils.checkAndClearPaintedState(element);
|
||||||
|
element.style.transform = "translateY(-5px)";
|
||||||
|
waitForAllPaintsFlushed(function () {
|
||||||
|
var painted = utils.checkAndClearPaintedState(element);
|
||||||
|
// BasicLayers' heuristics are so that even with will-change:transform,
|
||||||
|
// we can still have repaints.
|
||||||
|
if (utils.layerManagerType != "Basic") {
|
||||||
|
is(painted, false, "will-change checkTransformRepaint element should not have been painted");
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function runTest() {
|
||||||
|
var csscode = document.getElementById("csscode").firstChild.textContent;
|
||||||
|
var style = document.createElement("style");
|
||||||
|
style.textContent = csscode;
|
||||||
|
document.body.appendChild(style);
|
||||||
|
test_checkRepaint(function(){
|
||||||
|
test_checkOpacityRepaint(function(){
|
||||||
|
test_checkTransformRepaint(function(){
|
||||||
|
SimpleTest.finish();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
SpecialPowers.pushPrefEnv({ "set": [["layout.css.will-change.enabled", true]] }, runTest);
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</html>
|
Загрузка…
Ссылка в новой задаче