-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
background-color-transition-with-delay.html
42 lines (40 loc) · 1.39 KB
/
background-color-transition-with-delay.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-color">
<link rel="match" href="background-color-transition-with-delay-ref.html">
<style>
.container {
width: 100px;
height: 100px;
background-color: rgb(0, 200, 0);
transition: background-color 200000ms steps(2) -99999.9ms;
}
</style>
<script src="/common/reftest-wait.js"></script>
<body>
<div class="container" id="target"></div>
<script>
// This test differs from "background-color-transition.html" because it runs the
// transition starting from the set background color, rather than using a
// delay to start in the middle of the transition. This tests a new codepath
// where the first frame of the transition has the original background color,
// which is why we need the transition fully running. Since we are using the
// step(2) in the animation, so it is enough to wait for two frames and the
// animation should be in its mid-point, that's the time we should take
// screenshot.
function startTransition() {
requestAnimationFrame(() => {
document.getElementById('target').style.backgroundColor = "rgb(200, 0, 0)";
document.getAnimations()[0].ready.then(() => {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
takeScreenshot();
});
});
});
});
}
requestAnimationFrame(startTransition);
</script>
</body>
</html>