layout/style/test/test_transitions_step_functions.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/test/test_transitions_step_functions.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=435441
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 435441</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="application/javascript" src="animation_utils.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +  <style type="text/css">
    1.15 +
    1.16 +  p.transition {
    1.17 +    transition: margin-top 100s linear;
    1.18 +  }
    1.19 +
    1.20 +  </style>
    1.21 +</head>
    1.22 +<body>
    1.23 +<div id="display">
    1.24 +
    1.25 +</div>
    1.26 +<pre id="test">
    1.27 +<script type="application/javascript">
    1.28 +
    1.29 +/** Test for transition step functions **/
    1.30 +
    1.31 +var display = document.getElementById("display");
    1.32 +
    1.33 +function run_test(tf, percent, value)
    1.34 +{
    1.35 +  var p = document.createElement("p");
    1.36 +  p.className = "transition";
    1.37 +  p.style.marginTop = "0px";
    1.38 +  // be this percent of the way through a 100s transition
    1.39 +  p.style.transitionDelay = (percent * -100) + "s";
    1.40 +  p.style.transitionTimingFunction = tf;
    1.41 +  display.appendChild(p);
    1.42 +  var cs = getComputedStyle(p, "");
    1.43 +  var flush1 = cs.marginTop;
    1.44 +
    1.45 +  p.style.marginTop = "1000px";
    1.46 +  var result = px_to_num(cs.marginTop) / 1000
    1.47 +
    1.48 +  is(result, value, 100 * percent + "% of the way through " + tf);
    1.49 +
    1.50 +  display.removeChild(p);
    1.51 +}
    1.52 +
    1.53 +run_test("step-start", 0, 0);
    1.54 +run_test("step-start", 0.001, 1);
    1.55 +run_test("step-start", 0.999, 1);
    1.56 +run_test("step-start", 1, 1);
    1.57 +run_test("step-end", 0, 0);
    1.58 +run_test("step-end", 0.001, 0);
    1.59 +run_test("step-end", 0.999, 0);
    1.60 +run_test("step-end", 1, 1);
    1.61 +
    1.62 +run_test("steps(2)", 0.00, 0.0);
    1.63 +run_test("steps(2)", 0.49, 0.0);
    1.64 +run_test("steps(2)", 0.50, 0.5);
    1.65 +run_test("steps(2)", 0.99, 0.5);
    1.66 +run_test("steps(2)", 1.00, 1.0);
    1.67 +
    1.68 +run_test("steps(2, end)", 0.00, 0.0);
    1.69 +run_test("steps(2, end)", 0.49, 0.0);
    1.70 +run_test("steps(2, end)", 0.50, 0.5);
    1.71 +run_test("steps(2, end)", 0.99, 0.5);
    1.72 +run_test("steps(2, end)", 1.00, 1.0);
    1.73 +
    1.74 +run_test("steps(2, start)", 0.00, 0.0);
    1.75 +run_test("steps(2, start)", 0.01, 0.5);
    1.76 +run_test("steps(2, start)", 0.50, 0.5);
    1.77 +run_test("steps(2, start)", 0.51, 1.0);
    1.78 +run_test("steps(2, start)", 1.00, 1.0);
    1.79 +
    1.80 +run_test("steps(8,end)", 0.00, 0.0);
    1.81 +run_test("steps(8,end)", 0.10, 0.0);
    1.82 +run_test("steps(8,end)", 0.20, 0.125);
    1.83 +run_test("steps(8,end)", 0.30, 0.25);
    1.84 +run_test("steps(8,end)", 0.40, 0.375);
    1.85 +run_test("steps(8,end)", 0.49, 0.375);
    1.86 +run_test("steps(8,end)", 0.50, 0.5);
    1.87 +run_test("steps(8,end)", 0.60, 0.5);
    1.88 +run_test("steps(8,end)", 0.70, 0.625);
    1.89 +run_test("steps(8,end)", 0.80, 0.75);
    1.90 +run_test("steps(8,end)", 0.90, 0.875);
    1.91 +run_test("steps(8,end)", 1.00, 1.0);
    1.92 +
    1.93 +</script>
    1.94 +</pre>
    1.95 +</body>
    1.96 +</html>

mercurial