Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Tests for MozAfterPaint</title> |
michael@0 | 5 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script> |
michael@0 | 7 | <!-- This CSS must not be parsed before we get a change to set layout.css.will-change.enabled=true --> |
michael@0 | 8 | <script type="css_but_do_not_parse" id="csscode"> |
michael@0 | 9 | #checkOpacityRepaint { |
michael@0 | 10 | will-change: opacity; |
michael@0 | 11 | } |
michael@0 | 12 | #checkTransformRepaint { |
michael@0 | 13 | will-change: transform; |
michael@0 | 14 | } |
michael@0 | 15 | div { |
michael@0 | 16 | width: 100px; |
michael@0 | 17 | height: 100px; |
michael@0 | 18 | background: radial-gradient(ellipse at center, #87e0fd 0%,#53cbf1 40%,#05abe0 100%); |
michael@0 | 19 | } |
michael@0 | 20 | </script> |
michael@0 | 21 | </head> |
michael@0 | 22 | <body> |
michael@0 | 23 | <div id="checkRepaint"> |
michael@0 | 24 | Check repaint without will-change |
michael@0 | 25 | </div> |
michael@0 | 26 | <div id="checkOpacityRepaint"> |
michael@0 | 27 | Check repaint with will-change |
michael@0 | 28 | </div> |
michael@0 | 29 | <div id="checkTransformRepaint"> |
michael@0 | 30 | Check repaint with will-change |
michael@0 | 31 | </div> |
michael@0 | 32 | </body> |
michael@0 | 33 | <script> |
michael@0 | 34 | |
michael@0 | 35 | var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). |
michael@0 | 36 | getInterface(Components.interfaces.nsIDOMWindowUtils); |
michael@0 | 37 | |
michael@0 | 38 | var initialPaintCount = 0; |
michael@0 | 39 | |
michael@0 | 40 | function test_checkRepaint(next) { |
michael@0 | 41 | var element = document.getElementById("checkRepaint"); |
michael@0 | 42 | waitForAllPaintsFlushed(function () { |
michael@0 | 43 | utils.checkAndClearPaintedState(element); |
michael@0 | 44 | element.style.opacity = "0.5"; |
michael@0 | 45 | waitForAllPaintsFlushed(function () { |
michael@0 | 46 | var painted = utils.checkAndClearPaintedState(element); |
michael@0 | 47 | // *** We check that this repaints because the test is relying |
michael@0 | 48 | // on this property. If this is broken then this test wont |
michael@0 | 49 | // be reliable check for will-change. |
michael@0 | 50 | is(painted, true, "element should have been painted"); |
michael@0 | 51 | next(); |
michael@0 | 52 | }); |
michael@0 | 53 | }); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function test_checkOpacityRepaint(next) { |
michael@0 | 57 | var element = document.getElementById("checkOpacityRepaint"); |
michael@0 | 58 | waitForAllPaintsFlushed(function () { |
michael@0 | 59 | utils.checkAndClearPaintedState(element); |
michael@0 | 60 | element.style.opacity = "0.5"; |
michael@0 | 61 | waitForAllPaintsFlushed(function () { |
michael@0 | 62 | var painted = utils.checkAndClearPaintedState(element); |
michael@0 | 63 | // BasicLayers' heuristics are so that even with will-change:opacity, |
michael@0 | 64 | // we can still have repaints. |
michael@0 | 65 | if (utils.layerManagerType != "Basic") { |
michael@0 | 66 | is(painted, false, "will-change checkOpacityRepaint element should not have been painted"); |
michael@0 | 67 | } |
michael@0 | 68 | next(); |
michael@0 | 69 | }); |
michael@0 | 70 | }); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function test_checkTransformRepaint(next) { |
michael@0 | 74 | var element = document.getElementById("checkTransformRepaint"); |
michael@0 | 75 | waitForAllPaintsFlushed(function () { |
michael@0 | 76 | utils.checkAndClearPaintedState(element); |
michael@0 | 77 | element.style.transform = "translateY(-5px)"; |
michael@0 | 78 | waitForAllPaintsFlushed(function () { |
michael@0 | 79 | var painted = utils.checkAndClearPaintedState(element); |
michael@0 | 80 | // BasicLayers' heuristics are so that even with will-change:transform, |
michael@0 | 81 | // we can still have repaints. |
michael@0 | 82 | if (utils.layerManagerType != "Basic") { |
michael@0 | 83 | is(painted, false, "will-change checkTransformRepaint element should not have been painted"); |
michael@0 | 84 | } |
michael@0 | 85 | next(); |
michael@0 | 86 | }); |
michael@0 | 87 | }); |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | function runTest() { |
michael@0 | 91 | var csscode = document.getElementById("csscode").firstChild.textContent; |
michael@0 | 92 | var style = document.createElement("style"); |
michael@0 | 93 | style.textContent = csscode; |
michael@0 | 94 | document.body.appendChild(style); |
michael@0 | 95 | test_checkRepaint(function(){ |
michael@0 | 96 | test_checkOpacityRepaint(function(){ |
michael@0 | 97 | test_checkTransformRepaint(function(){ |
michael@0 | 98 | SimpleTest.finish(); |
michael@0 | 99 | }); |
michael@0 | 100 | }); |
michael@0 | 101 | }); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 105 | SpecialPowers.pushPrefEnv({ "set": [["layout.css.will-change.enabled", true]] }, runTest); |
michael@0 | 106 | |
michael@0 | 107 | </script> |
michael@0 | 108 | </html> |