|
4 | 4 | <script src="/resources/testharnessreport.js"></script>
|
5 | 5 | <script>
|
6 | 6 | test(function() {
|
7 |
| - let svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
8 |
| - let point = svgElement.createSVGPoint(); |
| 7 | + const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
| 8 | + const point = svgElement.createSVGPoint(); |
9 | 9 |
|
10 | 10 | // Check initial point values.
|
11 | 11 | assert_equals(point.x, 0);
|
12 | 12 | assert_equals(point.y, 0);
|
13 | 13 |
|
14 |
| - point.y = 2; |
15 |
| - |
16 |
| - // Check setting valid arguments. |
17 |
| - assert_equals(point.x, 0); |
18 |
| - assert_equals(point.y, 2); |
| 14 | + // Check assigning points. |
| 15 | + point.x = 100; |
| 16 | + assert_equals(point.x, 100); |
| 17 | + point.y = 200; |
| 18 | + assert_equals(point.y, 200); |
| 19 | + point.y = null; |
| 20 | + assert_equals(point.y, 0); |
| 21 | + point.y = 200; |
19 | 22 |
|
20 | 23 | // Check setting invalid arguments.
|
| 24 | + assert_throws_js(TypeError, function() { point.x = point; }); |
| 25 | + assert_equals(point.x, 100); |
21 | 26 | assert_throws_js(TypeError, function() { point.x = NaN; });
|
| 27 | + assert_equals(point.x, 100); |
22 | 28 | assert_throws_js(TypeError, function() { point.x = Infinity; });
|
23 |
| - assert_equals(point.x, 0); |
24 |
| -}); |
| 29 | + assert_equals(point.x, 100); |
| 30 | + |
| 31 | + assert_throws_js(TypeError, function() { point.y = point; }); |
| 32 | + assert_equals(point.y, 200); |
| 33 | + assert_throws_js(TypeError, function() { point.y = NaN; }); |
| 34 | + assert_equals(point.y, 200); |
| 35 | + assert_throws_js(TypeError, function() { point.y = Infinity; }); |
| 36 | + assert_equals(point.y, 200); |
| 37 | +}, `${document.title}, 'x' and 'y' attributes`); |
| 38 | + |
| 39 | +test(function() { |
| 40 | + const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
| 41 | + const point = svgElement.createSVGPoint(); |
| 42 | + |
| 43 | + point.x = -50; |
| 44 | + point.y = 100; |
| 45 | + |
| 46 | + // Multiply with -1,0,0,2,10,10 matrix, should flip x coordinate, multiply y |
| 47 | + // by two and translate each coordinate by 10. |
| 48 | + const ctm = svgElement.createSVGMatrix(); |
| 49 | + ctm.a = -1; |
| 50 | + ctm.d = 2; |
| 51 | + ctm.e = 10; |
| 52 | + ctm.f = 10; |
| 53 | + newPoint = point.matrixTransform(ctm); |
| 54 | + assert_true(newPoint instanceof SVGPoint); |
| 55 | + assert_equals(newPoint.x, 60); |
| 56 | + assert_equals(newPoint.y, 210); |
| 57 | + |
| 58 | + // Check invalid arguments for 'matrixTransform'. |
| 59 | + assert_throws_js(TypeError, function() { point.matrixTransform(); }); |
| 60 | + assert_throws_js(TypeError, function() { point.matrixTransform(-1); }); |
| 61 | + assert_throws_js(TypeError, function() { point.matrixTransform(5); }); |
| 62 | + assert_throws_js(TypeError, function() { point.matrixTransform('aString'); }); |
| 63 | + assert_throws_js(TypeError, function() { point.matrixTransform(point); }); |
| 64 | + assert_throws_js(TypeError, function() { point.matrixTransform(svgElement); }); |
| 65 | +}, `${document.title}, matrixTransform()`); |
25 | 66 | </script>
|
0 commit comments