|
1 |
| -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 1 | +<!DOCTYPE html> |
2 | 2 | <html lang="en">
|
3 | 3 | <head>
|
4 | 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
5 |
| - <title>Test of -webkit-animation-play-state</title> |
6 |
| - <style type="text/css" media="screen"> |
| 5 | + <title>Test of animation-play-state</title> |
| 6 | + <style> |
7 | 7 | body {
|
8 | 8 | margin: 0;
|
9 | 9 | }
|
|
16 | 16 | width: 100px;
|
17 | 17 | background-color: red;
|
18 | 18 | margin: 0;
|
19 |
| - -webkit-animation-duration: 2s; |
20 |
| - -webkit-animation-timing-function: linear; |
21 |
| - -webkit-animation-name: "move1"; |
22 |
| - -webkit-animation-play-state: running; |
| 19 | + animation-duration: 2s; |
| 20 | + animation-timing-function: linear; |
| 21 | + animation-name: move; |
| 22 | + animation-play-state: running; |
23 | 23 | }
|
24 |
| - #safezone { |
25 |
| - position: absolute; |
26 |
| - top: 100px; |
27 |
| - height: 100px; |
28 |
| - width: 200px; |
29 |
| - left: 100px; |
30 |
| - background-color: green; |
31 |
| - } |
32 |
| - @-webkit-keyframes "move1" { |
| 24 | + |
| 25 | + @keyframes move { |
33 | 26 | from { margin-left: 0px; }
|
34 | 27 | to { margin-left: 300px; }
|
35 | 28 | }
|
36 |
| - #result { |
37 |
| - color: white; /* hide from pixel results */ |
38 |
| - } |
39 | 29 | </style>
|
40 |
| - <script src="resources/animation-test-helpers.js" type="text/javascript" charset="utf-8"></script> |
41 |
| - <script type="text/javascript" charset="utf-8"> |
42 |
| - const expectedValues = [ |
43 |
| - // [animation-name, time, element-id, property, expected-value, tolerance] |
44 |
| - ["move1", 0.5, "box", "margin-left", 75, 20], |
45 |
| - ["move1", 1.0, "box", "margin-left", 150, 20], |
46 |
| - ["move1", 2.5, "box", "margin-left", 150, 20], |
47 |
| - ]; |
| 30 | + <script src="../resources/testharness.js"></script> |
| 31 | + <script src="../resources/testharnessreport.js"></script> |
| 32 | + <script src="resources/animation-test.js"></script> |
| 33 | +</head> |
| 34 | +<body> |
| 35 | +<div id="box"></div> |
| 36 | +<script> |
48 | 37 |
|
49 |
| - function pauseAnimation() |
50 |
| - { |
51 |
| - const box = document.getElementById("box"); |
52 |
| - box.style.webkitAnimationPlayState = "paused"; |
53 |
| - box.getAnimations()[0].currentTime = 1000; |
54 |
| - } |
| 38 | +async_test(async t => { |
| 39 | + const delay = 100; |
55 | 40 |
|
56 |
| - function setTimers() |
57 |
| - { |
58 |
| - setTimeout(pauseAnimation, 1000); |
59 |
| - } |
| 41 | + const test = new AnimationTest({ |
| 42 | + target: document.getElementById("box"), |
| 43 | + styleExtractor: style => parseFloat(style.marginLeft) |
| 44 | + }); |
60 | 45 |
|
61 |
| - runAnimationTest(expectedValues, setTimers, null, true); |
| 46 | + // Record two computed values after the specified delay each. |
| 47 | + await test.recordValueAfterRunningFor(delay); |
| 48 | + await test.recordValueAfterRunningFor(delay); |
62 | 49 |
|
63 |
| - </script> |
64 |
| -</head> |
65 |
| -<body> |
66 |
| -<!-- This tests the operation of -webkit-animation-play-state. After 1 second the red boxes should be hidden by the green boxes. You should see no red boxes. --> |
67 |
| -<div id="box"></div> |
68 |
| -<div id="safezone"></div> |
69 |
| -<div id="result"></div> |
| 50 | + // We'll now pause the animation using the CSS property "animation-play-state". |
| 51 | + box.style.animationPlayState = "paused"; |
| 52 | + |
| 53 | + // And now we'll record values after the specified delay each and check that those are the same. |
| 54 | + const initialPausedValue = await test.valueAfterWaitingFor(delay); |
| 55 | + const currentPausedValue = await test.valueAfterWaitingFor(delay); |
| 56 | + assert_equals(initialPausedValue, currentPausedValue, "Values recorded while paused are the same."); |
| 57 | + |
| 58 | + // Finally, check the values recorded earlier in the test. |
| 59 | + test.checkRecordedValues(); |
| 60 | + |
| 61 | + t.done(); |
| 62 | +}, `Pausing an animation using the animation-play-state property stops animating styles.`); |
| 63 | + |
| 64 | +</script> |
70 | 65 | </div>
|
71 | 66 | </body>
|
72 | 67 | </html>
|
0 commit comments