3 <script src=
"../../resources/js-test.js"></script>
6 @-webkit-keyframes example {
42 #before.animate:before {
46 -webkit-animation: example
2s;
47 -moz-animation: example
2s;
48 animation: example
2s;
53 display: inline-block;
54 border:
1px solid black;
64 <div id=
"before"></div>
65 <div id=
"after"></div>
68 description('Animations on :before and :after pseudo elements should run');
70 if (window
.testRunner
)
71 testRunner
.dumpAsText();
73 function getPseudoComputedTop(id
)
75 return Math
.round(parseFloat(getComputedStyle(document
.getElementById(id
), ':' + id
).top
));
78 // FIXME: This test should be modified so subpixel doesn't cause off by one
79 // below and it no longer needs shouldBeCloseTo.
81 function testAnimation(id
)
83 var div
= document
.getElementById(id
);
84 div
.className
= 'animate';
86 shouldBe('div.offsetWidth', '52');
87 if (window
.internals
) {
88 internals
.pauseAnimations(1);
89 shouldBeCloseTo('div.offsetWidth', 20, 1);
90 computedTop
= getPseudoComputedTop(id
);
91 shouldBeCloseTo('computedTop', 170, 1);
92 internals
.pauseAnimations(2);
93 shouldBeCloseTo('div.offsetWidth', 12, 1);
94 computedTop
= getPseudoComputedTop(id
);
95 shouldBeCloseTo('computedTop', 200, 1);
97 // This will be flaky, but it's a reasonable approximation for testing
98 // in a browser instead of DRT.
99 setTimeout(function() {
101 shouldBeCloseTo('div.offsetWidth', 20, 1);
102 computedTop
= getPseudoComputedTop(id
);
103 shouldBeCloseTo('computedTop', 170, 1);
105 setTimeout(function() {
107 shouldBeCloseTo('div.offsetWidth', 12, 1);
108 computedTop
= getPseudoComputedTop(id
);
109 shouldBeCloseTo('computedTop', 200, 1);
114 onload = function() {
115 testAnimation('before');
116 testAnimation('after');
117 if (window
.internals
)
118 isSuccessfullyParsed();
120 setTimeout(isSuccessfullyParsed
, 2000);