blob: 18ee4fd8a23e6a9b4f95068b418d4da1bdef1679 (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
#target {
background: green;
height: 50px;
width: 50px;
}
</style>
</head>
<body>
<div id="target"></div>
</body>
<script src="../../../testcommon.js"></script>
<script type="text/javascript">
function sendResult(message) {
top.postMessage(message, '*');
}
function waitForAnimationReady(anim) {
// Resolution of the ready promise, though UA dependent, is expected to
// happen within a few frames. Throttling rendering of the frame owning
// the animation's timeline may delay resolution of the ready promise,
// resulting in a test failure.
let frameTimeout = 10;
let resolved = false;
return new Promise((resolve, reject) => {
anim.ready.then(() => {
resolved = true;
resolve('PASS');
});
const tick = () => {
requestAnimationFrame(() => {
if (!resolved) {
if (--frameTimeout == 0)
resolve('FAIL: Animation is still pending');
else
tick();
}
});
};
tick();
});
}
function verifyAnimationIsUpdating() {
return new Promise(resolve => {
waitForAnimationFrames(3).then(() => {
const opacity = getComputedStyle(target).opacity;
const result =
(opacity == 1) ? 'FAIL: opacity remained unchanged' : 'PASS';
resolve(result);
});
});
}
async function runTest() {
const anim = document.getAnimations()[0];
if (!anim) {
setResult('FAIL: Failed to create animation');
return;
}
waitForAnimationReady(anim).then(result => {
if (result != 'PASS') {
sendResult(result);
return;
}
verifyAnimationIsUpdating().then(result => {
sendResult(result);
});
});
}
</script>
</html>
|