| Index: third_party/WebKit/LayoutTests/typedcssom/cssUnitValue_toMethod.html
|
| diff --git a/third_party/WebKit/LayoutTests/typedcssom/cssUnitValue_toMethod.html b/third_party/WebKit/LayoutTests/typedcssom/cssUnitValue_toMethod.html
|
| index 00f1a128e402a7d6de0852f0bcc466b97cf8446b..bccac27482f264a96936c1508ddfb27610958908 100644
|
| --- a/third_party/WebKit/LayoutTests/typedcssom/cssUnitValue_toMethod.html
|
| +++ b/third_party/WebKit/LayoutTests/typedcssom/cssUnitValue_toMethod.html
|
| @@ -12,6 +12,15 @@ let angleUnits = [
|
| 'turn'
|
| ];
|
|
|
| +let fixedLengthUnits = [
|
| + 'px',
|
| + 'in',
|
| + 'cm',
|
| + 'mm',
|
| + 'pt',
|
| + 'pc'
|
| +];
|
| +
|
| let conversionFactors = {
|
| 'deg': {
|
| 'deg': 1,
|
| @@ -37,6 +46,59 @@ let conversionFactors = {
|
| 'grad': 400,
|
| 'turn': 1,
|
| },
|
| + // 96 px per in
|
| + // 2.54 cm per in
|
| + // 10 mm per cm
|
| + // 72 pt per in
|
| + // 6 pc per in
|
| + 'px': {
|
| + 'px': 1,
|
| + 'in': 1 / 96,
|
| + 'cm': 2.54 / 96,
|
| + 'mm': 25.4 / 96,
|
| + 'pt': 72 / 96,
|
| + 'pc': 6 / 96
|
| + },
|
| + 'in': {
|
| + 'px': 96,
|
| + 'in': 1,
|
| + 'cm': 2.54,
|
| + 'mm': 25.4,
|
| + 'pt': 72,
|
| + 'pc': 6
|
| + },
|
| + 'cm': {
|
| + 'px': 96 / 2.54,
|
| + 'in': 1 / 2.54,
|
| + 'cm': 1,
|
| + 'mm': 10,
|
| + 'pt': 72 / 2.54,
|
| + 'pc': 6 / 2.54
|
| + },
|
| + 'mm': {
|
| + 'px': 96 / 25.4,
|
| + 'in': 1 / 25.4,
|
| + 'cm': 1 / 10,
|
| + 'mm': 1,
|
| + 'pt': 72 / 25.4,
|
| + 'pc': 6 / 25.4
|
| + },
|
| + 'pt': {
|
| + 'px': 96 / 72,
|
| + 'in': 1 / 72,
|
| + 'cm': 2.54 / 72,
|
| + 'mm': 25.4 / 72,
|
| + 'pt': 1,
|
| + 'pc': 6 / 72,
|
| + },
|
| + 'pc': {
|
| + 'px': 96 / 6,
|
| + 'in': 1 / 6,
|
| + 'cm': 2.54 / 6,
|
| + 'mm': 25.4 / 6,
|
| + 'pt': 72 / 6,
|
| + 'pc': 1
|
| + }
|
| }
|
|
|
| test(() => {
|
| @@ -65,4 +127,16 @@ for (let unit of angleUnits) {
|
| }
|
| }
|
|
|
| +for (let unit of fixedLengthUnits) {
|
| + for (let toUnit of fixedLengthUnits) {
|
| + test(() => {
|
| + let unitValue = new CSSUnitValue(1, unit);
|
| + let result = unitValue.to(toUnit);
|
| + assert_approx_equals(
|
| + result.value, conversionFactors[unit][toUnit], EPSILON);
|
| + assert_equals(result.unit, toUnit);
|
| + }, 'Converting fixed length unit ' + unit + ' to ' + toUnit);
|
| + }
|
| +}
|
| +
|
| </script>
|
|
|