2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
10 var element = document.getElementById('e');
13 var partialKeyframes1 = [
14 {opacity: '1', color: 'red'},
17 var partialKeyframes2 = [
19 {opacity: '0', color: 'red'}
21 var partialKeyframes3 = [
22 {opacity: '1', color: 'red'},
23 {opacity: '0', color: 'foo'}
25 var partialKeyframes4 = [
26 {opacity: '1', color: 'foo'},
27 {opacity: '0', color: 'red'}
30 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes1); });
31 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes2); });
32 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes3); });
33 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes4); });
34 }, 'Calling new Animation() with a mismatched keyframe property should throw a NotSupportedError.');
37 var validKeyframes1 = [
39 {opacity: '0.3', offset: 0.5},
40 {opacity: '0', offset: 1}
42 var validKeyframes2 = [
44 {height: '0px', offset: 0},
45 {width: '10px', height: '10px', offset: 1}
48 assert_not_equals(new Animation(element, validKeyframes1), undefined);
49 assert_not_equals(new Animation(element, validKeyframes2), undefined);
50 }, 'Calling new Animation() with no offset specified for the first keyframe should create and animation.');
53 var partialKeyframes1 = [
54 {opacity: '1', offset: 0.1},
55 {opacity: '0', offset: 1}
57 var partialKeyframes2 = [
58 {opacity: '1', offset: 0.1},
62 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes1); });
63 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes2); });
64 }, 'Calling new Animation() with the offset of the first keyframe specified but not equal to 0 should throw a NotSupportedError.');
67 var validKeyframes1 = [
68 {opacity: '1', offset: 0},
69 {opacity: '0.3', offset: 0.5},
72 var validKeyframes2 = [
73 {width: '0px', height: '0px', offset: 0},
74 {height: '10px', offset: 1},
78 assert_not_equals(new Animation(element, validKeyframes1), undefined);
79 assert_not_equals(new Animation(element, validKeyframes2), undefined);
80 }, 'Calling new Animation() with no offset specified for the last keyframe should create an animation.');
83 var partialKeyframes1 = [
84 {opacity: '1', offset: 0},
85 {opacity: '0', offset: 0.1}
87 var partialKeyframes2 = [
89 {opacity: '0', offset: 0.1}
92 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes1); });
93 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes2); });
94 }, 'Calling new Animation() with the offset of the last keyframe specified but not equal to 1 should throw a NotSupportedError.');
97 var partialKeyframes1 = [
98 {width: '0px', height: '0px', offset: 0},
100 {width: '10px', offset: 1}
102 var partialKeyframes2 = [
103 {width: '0px', height: '0px', offset: 0},
108 // Height is missing keyframe at offset: 1
109 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes1); });
110 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes2); });
111 }, 'Calling new Animation() with a keyframe that has no offset specified, is followed by other keyframes, ' +
112 'and is the last keyframe for a property, should throw a NotSupportedError.');
115 var partialKeyframes1 = [
116 {width: '0px', offset: 0},
118 {width: '10px', height: '10px', offset: 1}
120 var partialKeyframes2 = [
123 {width: '10px', height: '10px', offset: 1}
126 // Height is missing keyframe at offset: 0
127 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes1); });
128 assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes2); });
129 }, 'Calling new Animation() with a keyframe that has no offset specified, is preceded by other keyframes, ' +
130 'and is the first keyframe for a property, should throw a NotSupportedError.');