Commit 385810ad authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

CSS Animations: Fix flaky font-size-using-ems.html

The test font-size-using-ems.html needlessly used setTimeout
in an attempt to capture a snapshot of a property value while the
animation is in progress.

We now use a paused animation with negative start delay to avoid
flakiness. The test can now safely be enabled.

BUG=741795

Change-Id: I2703e48f67608f9526293160aecd5e45dfc89645
Reviewed-on: https://chromium-review.googlesource.com/569543Reviewed-by: default avatarnainar <nainar@chromium.org>
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486280}
parent dba107b0
This test performs an animation of the font-size property using 'em' units. It tests whether or not we are properly getting the default font-size. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text.
PASS
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<div id="box"></div>
<style>
body {
font-size: 30px;
}
#box {
animation-duration: 3s;
animation-timing-function: linear;
animation-delay: -1s;
animation-play-state: paused;
animation-name: anim;
}
@keyframes anim {
from { font-size: 1em; }
to { font-size: 2em; }
}
</style>
<script>
test(() => {
assert_equals(getComputedStyle(box).fontSize, '40px');
}, 'font-size animation using em units gets the default font size');
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test of font-size Animation Using em Units</title>
<style type="text/css" media="screen">
body {
font-family: "arial";
font-size: 10px;
}
#box {
position: absolute;
left: 0;
top: 100px;
height: 250px;
width: 400px;
border: 1px solid black;
animation-duration: 1s;
animation-timing-function: linear;
animation-name: anim;
}
@keyframes anim {
from { font-size: 1em; }
to { font-size: 2em; }
}
</style>
<script type="text/javascript" charset="utf-8">
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
result = "PASS";
const defaultTolerance = 1;
function isEqual(actual, desired, tolerance)
{
if (tolerance == undefined || tolerance == 0)
tolerance = defaultTolerance;
var diff = Math.abs(actual - desired);
return diff < tolerance;
}
function snapshot(expected)
{
if (result != "PASS")
return;
var fontSize = parseInt(window.getComputedStyle(document.getElementById('box')).fontSize);
if (!isEqual(fontSize, expected)) {
result = "FAIL(was:"+fontSize+", expected:"+expected+")";
}
}
function start()
{
setTimeout("snapshot(13)", 333);
window.setTimeout(function() {
document.getElementById('result').innerHTML = result;
if (window.testRunner)
testRunner.notifyDone();
}, 400);
}
document.addEventListener('animationstart', start, false);
</script>
</head>
<body>
This test performs an animation of the font-size property using 'em' units. It tests whether or not we are properly
getting the default font-size.
<div id="box">
Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text.
Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text.
</div>
<div id="result">
</div>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment