border-width-interpolation.html (4206B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>border-width interpolation</title> 4 <link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#border-width"> 5 <meta name="assert" content="border-width supports animation by computed value"> 6 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/css/support/interpolation-testcommon.js"></script> 10 11 <style> 12 .parent { 13 border-width: 30px; 14 } 15 .target { 16 width: 50px; 17 height: 50px; 18 background-color: black; 19 display: inline-block; 20 border: 2px solid orange; 21 margin: 18px; 22 border-width: 10px; 23 } 24 .expected { 25 background-color: green; 26 } 27 </style> 28 29 <body></body> 30 31 <script> 32 // As per https://bugzilla.mozilla.org/show_bug.cgi?id=137688, Firefox does not 33 // support getComputedStyle for shorthands. As such, we have one test for this 34 // which explicitly checks the shorthand variant, but most tests use one of the 35 // longhands instead. 36 function compareNotEmpty(actual, expected) { 37 assert_equals(actual, expected); 38 assert_not_equals(actual, ''); 39 } 40 41 test_interpolation({ 42 property: 'border-width', 43 from: '20px 40px 60px 80px', 44 to: '30px 50px 70px 90px', 45 comparisonFunction: compareNotEmpty, 46 }, [ 47 {at: -0.3, expect: '17px 37px 57px 77px'}, 48 {at: 0, expect: '20px 40px 60px 80px'}, 49 {at: 0.3, expect: '23px 43px 63px 83px'}, 50 {at: 0.6, expect: '26px 46px 66px 86px'}, 51 {at: 1, expect: '30px 50px 70px 90px'}, 52 {at: 1.5, expect: '35px 55px 75px 95px'} 53 ]); 54 55 test_interpolation({ 56 property: 'border-left-width', 57 from: neutralKeyframe, 58 to: '20px', 59 }, [ 60 {at: -0.3, expect: '7px'}, 61 {at: 0, expect: '10px'}, 62 {at: 0.3, expect: '13px'}, 63 {at: 0.6, expect: '16px'}, 64 {at: 1, expect: '20px'}, 65 {at: 1.5, expect: '25px'}, 66 ]); 67 68 test_interpolation({ 69 property: 'border-left-width', 70 from: 'initial', 71 to: '23px', 72 }, [ 73 {at: -0.3, expect: '0px'}, 74 {at: 0, expect: '3px'}, 75 {at: 0.3, expect: '9px'}, 76 {at: 0.6, expect: '15px'}, 77 {at: 1, expect: '23px'}, 78 {at: 1.5, expect: '33px'}, 79 ]); 80 81 test_interpolation({ 82 property: 'border-left-width', 83 from: 'inherit', 84 to: '20px', 85 }, [ 86 {at: -0.3, expect: '33px'}, 87 {at: 0, expect: '30px'}, 88 {at: 0.3, expect: '27px'}, 89 {at: 0.6, expect: '24px'}, 90 {at: 1, expect: '20px'}, 91 {at: 1.5, expect: '15px'}, 92 ]); 93 94 test_interpolation({ 95 property: 'border-left-width', 96 from: 'unset', 97 to: '23px', 98 }, [ 99 {at: -0.3, expect: '0px'}, 100 {at: 0, expect: '3px'}, 101 {at: 0.3, expect: '9px'}, 102 {at: 0.6, expect: '15px'}, 103 {at: 1, expect: '23px'}, 104 {at: 1.5, expect: '33px'}, 105 ]); 106 107 test_interpolation({ 108 property: 'border-left-width', 109 from: '0px', 110 to: '10px' 111 }, [ 112 {at: -0.3, expect: '0px'}, // CSS border-left-width can't be negative. 113 {at: 0, expect: '0px'}, 114 {at: 0.3, expect: '3px'}, 115 {at: 0.6, expect: '6px'}, 116 {at: 1, expect: '10px'}, 117 {at: 1.5, expect: '15px'} 118 ]); 119 120 test_interpolation({ 121 property: 'border-bottom-width', 122 from: 'thick', 123 to: '15px' 124 }, [ 125 {at: -2, expect: '0px'}, // CSS border-bottom-width can't be negative. 126 {at: -0.3, expect: '2px'}, 127 {at: 0, expect: '5px'}, 128 {at: 0.3, expect: '8px'}, 129 {at: 0.6, expect: '11px'}, 130 {at: 1, expect: '15px'}, 131 {at: 1.5, expect: '20px'} 132 ]); 133 134 test_interpolation({ 135 property: 'border-left-width', 136 from: 'medium', 137 to: '13px' 138 }, [ 139 {at: -2, expect: '0px'}, // CSS border-left-width can't be negative. 140 {at: -0.25, expect: '0.5px'}, 141 {at: 0, expect: '3px'}, 142 {at: 0.3, expect: '6px'}, 143 {at: 0.6, expect: '9px'}, 144 {at: 1, expect: '13px'}, 145 {at: 1.5, expect: '18px'} 146 ]); 147 148 test_interpolation({ 149 property: 'border-right-width', 150 from: 'thin', 151 to: '11px' 152 }, [ 153 {at: -2, expect: '0px'}, // CSS border-right-width can't be negative. 154 {at: -0.3, expect: '0px'}, // CSS border-right-width can't be negative. 155 {at: 0, expect: '1px'}, 156 {at: 0.3, expect: '4px'}, 157 {at: 0.6, expect: '7px'}, 158 {at: 1, expect: '11px'}, 159 {at: 1.5, expect: '16px'} 160 ]); 161 162 test_interpolation({ 163 property: 'border-top-width', 164 from: '15px', 165 to: 'thick' 166 }, [ 167 {at: -2, expect: '35px'}, 168 {at: -0.3, expect: '18px'}, 169 {at: 0, expect: '15px'}, 170 {at: 0.3, expect: '12px'}, 171 {at: 0.6, expect: '9px'}, 172 {at: 1, expect: '5px'}, 173 {at: 1.5, expect: '0px'} 174 ]); 175 </script>