|
Line 0
a/LayoutTests/css3/filters/composited-during-animation.html_sec1
|
|
|
1 |
<!DOCTYPE html> |
| 2 |
|
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<style> |
| 6 |
img { |
| 7 |
margin: 10px; |
| 8 |
} |
| 9 |
|
| 10 |
.animating img { |
| 11 |
-webkit-animation-duration: 2s !important; |
| 12 |
-webkit-animation-timing-function: linear !important; |
| 13 |
} |
| 14 |
|
| 15 |
#grayscale-box { |
| 16 |
-webkit-animation-name: grayscale-anim; |
| 17 |
-webkit-filter: grayscale(1); |
| 18 |
} |
| 19 |
|
| 20 |
#sepia-box { |
| 21 |
-webkit-animation: sepia-anim; |
| 22 |
-webkit-filter: sepia(1); |
| 23 |
} |
| 24 |
|
| 25 |
#saturate-box { |
| 26 |
-webkit-animation: saturate-anim; |
| 27 |
-webkit-filter: saturate(1); |
| 28 |
} |
| 29 |
|
| 30 |
#huerotate-box { |
| 31 |
-webkit-animation: huerotate-anim; |
| 32 |
-webkit-filter: hue-rotate(90deg); |
| 33 |
} |
| 34 |
|
| 35 |
#invert-box { |
| 36 |
-webkit-animation: invert-anim; |
| 37 |
-webkit-filter: invert(1); |
| 38 |
} |
| 39 |
|
| 40 |
#opacity-box { |
| 41 |
-webkit-animation: opacity-anim; |
| 42 |
-webkit-filter: opacity(0); |
| 43 |
} |
| 44 |
|
| 45 |
#brightness-box { |
| 46 |
-webkit-animation: brightness-anim; |
| 47 |
-webkit-filter: brightness(0); |
| 48 |
} |
| 49 |
|
| 50 |
#contrast-box { |
| 51 |
-webkit-animation: contrast-anim; |
| 52 |
-webkit-filter: contrast(0); |
| 53 |
} |
| 54 |
|
| 55 |
#blur-box { |
| 56 |
-webkit-animation: blur-anim; |
| 57 |
-webkit-filter: blur(10px); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
@-webkit-keyframes grayscale-anim { |
| 62 |
from { -webkit-filter: grayscale(0); } |
| 63 |
to { -webkit-filter: grayscale(1); } |
| 64 |
} |
| 65 |
|
| 66 |
@-webkit-keyframes sepia-anim { |
| 67 |
from { -webkit-filter: sepia(0); } |
| 68 |
to { -webkit-filter: sepia(1); } |
| 69 |
} |
| 70 |
|
| 71 |
@-webkit-keyframes saturate-anim { |
| 72 |
from { -webkit-filter: saturate(0); } |
| 73 |
to { -webkit-filter: saturate(1); } |
| 74 |
} |
| 75 |
|
| 76 |
@-webkit-keyframes huerotate-anim { |
| 77 |
from { -webkit-filter: hue-rotate(0); } |
| 78 |
to { -webkit-filter: hue-rotate(180deg); } |
| 79 |
} |
| 80 |
|
| 81 |
@-webkit-keyframes invert-anim { |
| 82 |
from { -webkit-filter: invert(0); } |
| 83 |
to { -webkit-filter: invert(1); } |
| 84 |
} |
| 85 |
|
| 86 |
@-webkit-keyframes opacity-anim { |
| 87 |
from { -webkit-filter: opacity(1); } |
| 88 |
to { -webkit-filter: opacity(0); } |
| 89 |
} |
| 90 |
|
| 91 |
@-webkit-keyframes brightness-anim { |
| 92 |
from { -webkit-filter: brightness(1); } |
| 93 |
to { -webkit-filter: brightness(0); } |
| 94 |
} |
| 95 |
|
| 96 |
@-webkit-keyframes contrast-anim { |
| 97 |
from { -webkit-filter: contrast(1); } |
| 98 |
to { -webkit-filter: contrast(0); } |
| 99 |
} |
| 100 |
|
| 101 |
@-webkit-keyframes blur-anim { |
| 102 |
from { -webkit-filter: blur(0); } |
| 103 |
to { -webkit-filter: blur(20px); } |
| 104 |
} |
| 105 |
|
| 106 |
</style> |
| 107 |
<script src="../../animations/resources/animation-test-helpers.js"></script> |
| 108 |
<script type="text/javascript"> |
| 109 |
|
| 110 |
const preExpectedValues = [ |
| 111 |
// [element-id, property, expected-value] |
| 112 |
["grayscale-box", "webkitFilter", 'grayscale(1)'], |
| 113 |
["sepia-box", "webkitFilter", 'sepia(1)'], |
| 114 |
["saturate-box", "webkitFilter", 'saturate(1)'], |
| 115 |
["huerotate-box", "webkitFilter", 'hue-rotate(90deg)'], |
| 116 |
["invert-box", "webkitFilter", 'invert(1)'], |
| 117 |
["opacity-box", "webkitFilter", 'opacity(0)'], |
| 118 |
["brightness-box", "webkitFilter", 'brightness(0)'], |
| 119 |
["contrast-box", "webkitFilter", 'contrast(0)'], |
| 120 |
["blur-box", "webkitFilter", 'blur(10px)'], |
| 121 |
]; |
| 122 |
|
| 123 |
const expectedValues = [ |
| 124 |
// [animation-name, time, element-id, property, expected-value, tolerance] |
| 125 |
["grayscale-anim", 1, "grayscale-box", "webkitFilter", 'grayscale(0.5)', 0.15], |
| 126 |
["sepia-anim", 1, "sepia-box", "webkitFilter", 'sepia(0.5)', 0.15], |
| 127 |
["saturate-anim", 1, "saturate-box", "webkitFilter", 'saturate(0.5)', 0.15], |
| 128 |
["huerotate-anim", 1, "huerotate-box", "webkitFilter", 'hue-rotate(90deg)', 20], |
| 129 |
["invert-anim", 1, "invert-box", "webkitFilter", 'invert(0.5)', 0.15], |
| 130 |
["opacity-anim", 1, "opacity-box", "webkitFilter", 'opacity(0.5)', 0.15], |
| 131 |
["brightness-anim", 1, "brightness-box", "webkitFilter", 'brightness(0.5)', 0.15], |
| 132 |
["contrast-anim", 1, "contrast-box", "webkitFilter", 'contrast(0.5)', 0.15], |
| 133 |
["blur-anim", 1, "blur-box", "webkitFilter", 'blur(10px)', 4], |
| 134 |
]; |
| 135 |
|
| 136 |
function runPreTest() { |
| 137 |
var preResult = ""; |
| 138 |
|
| 139 |
for (var i=0; i < preExpectedValues.length; i++) { |
| 140 |
var id = preExpectedValues[i][0]; |
| 141 |
var prop = preExpectedValues[i][1]; |
| 142 |
var expected = preExpectedValues[i][2]; |
| 143 |
var element = document.getElementById(id); |
| 144 |
var computedStyle = window.getComputedStyle(element)[prop]; |
| 145 |
if (computedStyle == expected) |
| 146 |
preResult += "PASS: Element " + id + " had filter value " + expected + " before animation.<br>"; |
| 147 |
else |
| 148 |
preResult += "FAIL: Element " + id + " had filter value " + computedStyle + " rather than " + expected + " before animation.<br>"; |
| 149 |
} |
| 150 |
document.getElementById("preresult").innerHTML = preResult; |
| 151 |
|
| 152 |
// Completed the pre-animation tests. Now start the animation. |
| 153 |
setTimeout(function () { |
| 154 |
document.body.className = "animating"; |
| 155 |
runAnimationTest(expectedValues); |
| 156 |
}, 0); |
| 157 |
} |
| 158 |
|
| 159 |
if (window.layoutTestController) { |
| 160 |
layoutTestController.dumpAsText(); |
| 161 |
layoutTestController.waitUntilDone(); |
| 162 |
} |
| 163 |
|
| 164 |
window.addEventListener("load", runPreTest, false); |
| 165 |
</script> |
| 166 |
</head> |
| 167 |
<body> |
| 168 |
|
| 169 |
<img src="resources/reference.png" id="grayscale-box"> |
| 170 |
<img src="resources/reference.png" id="sepia-box"> |
| 171 |
<img src="resources/reference.png" id="saturate-box"> |
| 172 |
<img src="resources/reference.png" id="huerotate-box"> |
| 173 |
<img src="resources/reference.png" id="invert-box"> |
| 174 |
<img src="resources/reference.png" id="opacity-box"> |
| 175 |
<img src="resources/reference.png" id="brightness-box"> |
| 176 |
<img src="resources/reference.png" id="contrast-box"> |
| 177 |
<img src="resources/reference.png" id="blur-box"> |
| 178 |
|
| 179 |
<!-- this result element is filled in the script above, before the animations start --> |
| 180 |
<div id="preresult"> |
| 181 |
</div> |
| 182 |
|
| 183 |
<!-- this result element is filled by the animation test system --> |
| 184 |
<div id="result"> |
| 185 |
</div> |
| 186 |
</body> |
| 187 |
</html> |