summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/transitions/interrupt-transform-transition.html
blob: 83a48d70c83ed3665619295f9cdaf3c856c755e1 (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
<html>
<head>
  <style>
    .box {
      position: relative;
      top: 0;
      left: 0;
      width: 100px;
      height: 100px;
      background-color: blue;
      -webkit-transition-property: -webkit-transform;
      -webkit-transition-duration: 2s;
      -webkit-transform: translate(0, 0);
    }
  </style>
  <script>
    if (window.testRunner) {
      testRunner.dumpAsText();
      testRunner.waitUntilDone();
    }

    function test()
    {
      var t = window.getComputedStyle(document.getElementById('box')).webkitTransform;
      // grab the x value from the matrix()
      var lastValueRE = /([\.\d]+),[^,]+\)$/;
      var xTranslate = lastValueRE.exec(t)[1];
      var result = (xTranslate > 0) ? 'PASS' : 'FAIL: transition should be re-targeted from 200px in x, so x > 0';
      document.getElementById('result').innerHTML = result;

      if (window.testRunner)
          testRunner.notifyDone();
    }

    function startTest()
    {
      var box = document.getElementById('box');
      box.style.webkitTransform = 'translate(200px, 0)';
      
      window.setTimeout(function() {
        box.style.webkitTransform = 'translate(0, 200px)';
        window.setTimeout(test, 0);
      }, 300);

    }
  </script>
</head>
<body onload="startTest()">
  <p>Interrupted transition should not jump back to pre-transition transform</p>
  <div id="box" class="box">
  </div>
  <div id="result">
  </div>
</body>
</html>