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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<body>
<div id='e'></div>
</body>
<script>
var element = document.getElementById('e');
var keyframes = [{opacity: '1', offset: 0}, {opacity: '0', offset: 1}];
var keyframeEffectBasic = new KeyframeEffect(element, keyframes);
var specifiedTimingBasic = keyframeEffectBasic.timing;
var timingNumberDuration = {duration: 2};
var animationNumberDuration = new KeyframeEffect(element, keyframes, timingNumberDuration);
var specifiedTimingNumberDuration = animationNumberDuration.timing;
var timingNoDuration = {iterations: 3};
var animationNoDuration = new KeyframeEffect(element, keyframes, timingNoDuration);
var specifiedTimingNoDuration = animationNoDuration.timing;
var timingAllFields = {
delay: 2,
endDelay: 0.5,
fill: 'backwards',
iterationStart: 2,
iterations: 10,
duration: 5,
playbackRate: 2,
direction: 'reverse',
easing: 'step-start'
};
var animationAllFields = new KeyframeEffect(element, keyframes, timingAllFields);
var specifiedTimingAllFields = animationAllFields.timing;
test(function() {
assert_equals(specifiedTimingBasic.constructor, AnimationEffectTiming);
assert_equals(specifiedTimingBasic.delay, 0);
assert_equals(specifiedTimingBasic.endDelay, 0);
assert_equals(specifiedTimingBasic.fill, 'auto');
assert_equals(specifiedTimingBasic.iterationStart, 0);
assert_equals(specifiedTimingBasic.iterations, 1);
assert_equals(specifiedTimingBasic.duration, 'auto');
assert_equals(specifiedTimingBasic.playbackRate, 1);
assert_equals(specifiedTimingBasic.direction, 'normal');
assert_equals(specifiedTimingBasic.easing, 'linear');
}, 'TimedItem.timing should return a TimedItemTiming, which should have a getter for each member of the underlying Timing object.');
test(function() {
assert_equals(specifiedTimingNumberDuration.duration, 2);
}, 'TimedItem.timing.duration should return a number when duration was set as a number.');
test(function() {
assert_equals(specifiedTimingNoDuration.duration, 'auto');
}, 'TimedItem.timing.duration should return "auto" when duration was not specified.');
test(function() {
assert_equals(specifiedTimingAllFields.delay, 2);
assert_equals(specifiedTimingAllFields.endDelay, 0.5);
assert_equals(specifiedTimingAllFields.fill, 'backwards');
assert_equals(specifiedTimingAllFields.iterationStart, 2);
assert_equals(specifiedTimingAllFields.iterations, 10);
assert_equals(specifiedTimingAllFields.duration, 5);
assert_equals(specifiedTimingAllFields.playbackRate, 2);
assert_equals(specifiedTimingAllFields.direction, 'reverse');
assert_equals(specifiedTimingAllFields.easing, 'step-start');
}, 'TimedItem.timing should have a getter for each member of the underlying Timing object.');
</script>
|