OLD | NEW |
(Empty) | |
| 1 <script src="../../resources/testharness.js"></script> |
| 2 <script src="../../resources/testharnessreport.js"></script> |
| 3 |
| 4 <div id="testElement"></div> |
| 5 |
| 6 <script> |
| 7 |
| 8 var EPSILON = 1e-6; // float epsilon |
| 9 |
| 10 function validateTransformWithSingleRotation(transform, x, y, z, angle, cssStrin
g) { |
| 11 assert_equals(transform.cssString, cssString); |
| 12 |
| 13 // Shouldn't be base StyleValue as for unsupported values. |
| 14 assert_true(transform instanceof TransformValue); |
| 15 |
| 16 var components = [...transform.values()]; |
| 17 assert_equals(components.length, 1); |
| 18 assert_true(components[0] instanceof CSSRotation); |
| 19 assert_equals(components[0].cssString, cssString); |
| 20 |
| 21 assert_approx_equals(components[0].angle, angle, EPSILON); |
| 22 assert_approx_equals(components[0].x, x, EPSILON); |
| 23 assert_approx_equals(components[0].y, y, EPSILON); |
| 24 assert_approx_equals(components[0].z, z, EPSILON); |
| 25 } |
| 26 |
| 27 test(function() { |
| 28 testElement.style.transform = "rotate(30deg)"; |
| 29 |
| 30 validateTransformWithSingleRotation( |
| 31 testElement.styleMap.get("transform"), |
| 32 0, 0, 1, 30, |
| 33 "rotate(30deg)"); |
| 34 }, "Simple rotation read from a StyleMap is correct"); |
| 35 |
| 36 test(function() { |
| 37 testElement.style.transform = "rotate(10rad)"; |
| 38 |
| 39 validateTransformWithSingleRotation( |
| 40 testElement.styleMap.get("transform"), |
| 41 0, 0, 1, 572.957795, |
| 42 "rotate(572.958deg)"); |
| 43 }, "Simple rotation using radians read from a StyleMap is correct"); |
| 44 |
| 45 test(function() { |
| 46 testElement.style.transform = "rotate(20grad)"; |
| 47 |
| 48 validateTransformWithSingleRotation( |
| 49 testElement.styleMap.get("transform"), |
| 50 0, 0, 1, 18, |
| 51 "rotate(18deg)"); |
| 52 }, "Simple rotation using gradians read from a StyleMap is correct"); |
| 53 |
| 54 test(function() { |
| 55 testElement.style.transform = "rotate(0.5turn)"; |
| 56 |
| 57 validateTransformWithSingleRotation( |
| 58 testElement.styleMap.get("transform"), |
| 59 0, 0, 1, 180, |
| 60 "rotate(180deg)"); |
| 61 }, "Simple rotation using turns read from a StyleMap is correct"); |
| 62 |
| 63 test(function() { |
| 64 testElement.style.transform = "rotate3d(1, 2, 3, 30deg)"; |
| 65 validateTransformWithSingleRotation( |
| 66 testElement.styleMap.get("transform"), |
| 67 1, 2, 3, 30, |
| 68 "rotate3d(1, 2, 3, 30deg)"); |
| 69 }, "rotate3d read from a StyleMap is correct"); |
| 70 |
| 71 test(function() { |
| 72 testElement.style.transform = "rotateX(45deg)"; |
| 73 validateTransformWithSingleRotation( |
| 74 testElement.styleMap.get("transform"), |
| 75 1, 0, 0, 45, |
| 76 "rotate3d(1, 0, 0, 45deg)"); |
| 77 }, "rotateX read from a StyleMap results in a rotate3d"); |
| 78 |
| 79 test(function() { |
| 80 testElement.style.transform = "rotateX(1rad)"; |
| 81 validateTransformWithSingleRotation( |
| 82 testElement.styleMap.get("transform"), |
| 83 1, 0, 0, 57.29578, |
| 84 "rotate3d(1, 0, 0, 57.2958deg)"); |
| 85 }, "rotateX with units other than degrees"); |
| 86 |
| 87 test(function() { |
| 88 testElement.style.transform = "rotateY(80deg)"; |
| 89 validateTransformWithSingleRotation( |
| 90 testElement.styleMap.get("transform"), |
| 91 0, 1, 0, 80, |
| 92 "rotate3d(0, 1, 0, 80deg)"); |
| 93 }, "rotateY read from a StyleMap results in a rotate3d"); |
| 94 |
| 95 test(function() { |
| 96 testElement.style.transform = "rotateY(2grad)"; |
| 97 validateTransformWithSingleRotation( |
| 98 testElement.styleMap.get("transform"), |
| 99 0, 1, 0, 1.8, |
| 100 "rotate3d(0, 1, 0, 1.8deg)"); |
| 101 }, "rotateY with units other than degrees"); |
| 102 |
| 103 test(function() { |
| 104 testElement.style.transform = "rotateZ(100deg)"; |
| 105 validateTransformWithSingleRotation( |
| 106 testElement.styleMap.get("transform"), |
| 107 0, 0, 1, 100, |
| 108 "rotate3d(0, 0, 1, 100deg)"); |
| 109 }, "rotateZ read from a StyleMap results in a rotate3d"); |
| 110 |
| 111 test(function() { |
| 112 testElement.style.transform = "rotateZ(1turn)"; |
| 113 validateTransformWithSingleRotation( |
| 114 testElement.styleMap.get("transform"), |
| 115 0, 0, 1, 360, |
| 116 "rotate3d(0, 0, 1, 360deg)"); |
| 117 }, "rotateZ with units other than degrees"); |
| 118 |
| 119 </script> |
OLD | NEW |