<!doctype html>
<html>
<head>
  <title>Test simple fill mode on transform</title>
  <style>
    .box {
      position: relative;
      left: 10px;
      top: 10px;
      height: 100px;
      width: 100px;
      -webkit-transform: translate3d(100px, 0, 0);
      -webkit-animation-delay: 0.1s;
      -webkit-animation-duration: 0.1s;
      -webkit-animation-timing-function: linear;
      -webkit-animation-name: anim;
    }
    @-webkit-keyframes anim {
        from { -webkit-transform: translate3d(200px, 0, 0); }
        to   { -webkit-transform: translate3d(300px, 0, 0); }
    }
    #a {
      background-color: #f99;
      -webkit-animation-fill-mode: both;
      -webkit-animation-iteration-count: 2;
      -webkit-animation-direction: reverse;
    }
    #b {
      background-color: #999;
      -webkit-animation-fill-mode: both;
      -webkit-animation-iteration-count: 2;
      -webkit-animation-direction: alternate-reverse;
    }
  </style>
  <script src="resources/animation-test-helpers.js"></script>
  <script>
    const numAnims = 1;
    var animsFinished = 0;
    const allowance = 5;
    const expectedValues = [
      {id: "a", start: 300, end: 200},
      {id: "b", start: 300, end: 300}
    ];
    var result = "";

    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    function animationEnded(event) {
        if (++animsFinished == numAnims) {
            setTimeout(endTest, 0); // This call to setTimeout should be ok in the test environment
                                    // since we're just giving style a chance to resolve.
        }
    };

    function endTest() {

        for (var i = 0; i < expectedValues.length; i++) {
            var realValue = getPropertyValue("webkitTransform.4", expectedValues[i].id);
            var expectedValue = expectedValues[i].end;
            if (comparePropertyValue("webkitTransform.4", realValue, expectedValue, allowance))
                result += "PASS";
            else
                result += "FAIL";
            result += " - end of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
        }
        document.getElementById('result').innerHTML = result;

        if (window.testRunner)
            testRunner.notifyDone();
    }
    
    window.onload = function () {
      for (var i = 0; i < expectedValues.length; i++) {
          var realValue = getPropertyValue("webkitTransform.4", expectedValues[i].id);
          var expectedValue = expectedValues[i].start;
          if (comparePropertyValue("webkitTransform.4", realValue, expectedValue, allowance))
              result += "PASS";
          else
              result += "FAIL";
          result += " - start of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
      }
      document.addEventListener("webkitAnimationEnd", animationEnded, false);
    };

  </script>
</head>
<body>
This test performs an animation of the transform property with different
fill modes. It animates over 0.1 second with a 0.1 second delay.
It takes snapshots at document load and the end of the animations.
<div id="a" class="box">
  Both Iterate - Reverse
</div>
<div id="b" class="box">
  Both Iterate - Alternate Reverse
</div>
<div id="result">
</div>
</body>
</html>
