Bug 1545675 [wpt PR 16364] - WPT/BGPT: Add animation stop and set time tests, make...
[gecko.git] / testing / web-platform / tests / css / css-variables / variable-transitions-transition-property-all-before-value.html
blob5e54cd930f92208d29bd321aaf8880f97b1ab420
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>CSS Variables - Transitions - Variable value specified before transition; 'all' keyword used</title>
6 <meta rel="author" title="Kevin Babbitt">
7 <meta rel="author" title="Greg Whitworth">
8 <link rel="author" title="Microsoft Corporation" href="http://microsoft.com" />
9 <link rel="help" href="http://www.w3.org/TR/css-variables-1/#syntax">
11 <script src="/resources/testharness.js"></script>
12 <script src="/resources/testharnessreport.js"></script>
14 <style>
15 #target
17 transition-property: all;
18 transition-duration: 1s;
20 #target
22 --value: blue;
23 color: var(--value);
25 #target.changed
27 --value: green;
29 </style>
30 </head>
31 <body>
33 <div id="target">This text should transition from blue to green over a period of 1 second.</div>
35 <script type="text/javascript">
36 "use strict";
38 // Force an initial layout pass
39 document.documentElement.offsetHeight;
41 test(function() {
42 assert_equals(window.getComputedStyle(document.getElementById("target")).getPropertyValue("--value").trim(), "blue", "--value is blue before transition runs");
43 }, "Verify CSS variable value before transition");
45 test(function() {
46 // Different browsers generate interpolated colors differently, so check multiple valid forms.
47 assert_in_array(window.getComputedStyle(document.getElementById("target")).getPropertyValue("color").trim(),
48 ["rgb(0, 0, 255)", "rgba(0, 0, 255, 1)"],
49 "color is blue before transition runs");
50 }, "Verify substituted color value before transition");
52 var afterAnimationVariableTest = async_test("Verify CSS variable value after transition");
53 document.getElementById("target").addEventListener("transitionend", afterAnimationVariableTest.step_func_done(function() {
54 assert_equals(window.getComputedStyle(document.getElementById("target")).getPropertyValue("--value").trim(), "green", "--value is green after transition runs")
55 }));
57 var afterAnimationColorTest = async_test("Verify substituted color value after transition");
58 document.getElementById("target").addEventListener("transitionend", afterAnimationColorTest.step_func_done(function() {
59 assert_in_array(window.getComputedStyle(document.getElementById("target")).getPropertyValue("color").trim(),
60 ["rgb(0, 128, 0)", "rgba(0, 128, 0, 1)"],
61 "color is green after transition runs")
62 }));
64 // Trigger transition
65 document.getElementById("target").className = "changed";
67 // Force another layout pass
68 document.documentElement.offsetHeight;
69 </script>
71 </body>
72 </html>