OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE html> |
2 <html> | 2 <script src="../../resources/testharness.js"></script> |
3 <!-- Test that svg bounding boxes are valid for a zero-width or zero-height elli
pse --> | 3 <script src="../../resources/testharnessreport.js"></script> |
4 <head> | 4 <title>SVG bounding boxes are valid for a zero-rx or zero-ry ellipse</title> |
5 <script type="text/javascript"> | 5 <svg height="0"> |
6 function checkBoundingBoxHasZeroValue() { | 6 <ellipse cx="50" cy="100" rx="0" ry="50"/> |
7 if (window.testRunner) | 7 <ellipse cx="50" cy="100" rx="50" ry="0"/> |
8 window.testRunner.dumpAsText(); | 8 <ellipse vector-effect="non-scaling-stroke" cx="50" cy="100" rx="0" ry="50"/> |
9 var ellipse1 = document.getElementById('ellipse1').getBBox(); | 9 <ellipse vector-effect="non-scaling-stroke" cx="50" cy="100" rx="50" ry="0"/> |
10 var ellipse2 = document.getElementById('ellipse2').getBBox(); | 10 </svg> |
11 var ellipse3 = document.getElementById('ellipse3').getBBox(); | 11 <script> |
12 var ellipse4 = document.getElementById('ellipse4').getBBox(); | 12 BBox = function(x,y,w,h) { |
13 var results = "FAIL"; | 13 this.x = x; |
14 if (ellipse1.height == 100 && | 14 this.y = y; |
15 ellipse1.width == 0 && | 15 this.width = w; |
16 ellipse2.height == 0 && | 16 this.height = h; |
17 ellipse2.width == 100 && | 17 }; |
18 ellipse3.height == 100 && | 18 BBox.prototype.toString = function() { |
19 ellipse3.width == 0 && | 19 return this.x + "," + this.y + "," + this.width + "," + this.height; |
20 ellipse4.height == 0 && | 20 }; |
21 ellipse4.width == 100) | 21 // The order of expected sizes should equal the document order of the rects. |
22 results = "PASS"; | 22 var expectedBoxes = [ |
23 document.body.innerHTML = results + ", bounding boxes sizes are
(" + | 23 new BBox(50, 50, 0, 100), |
24 ellipse1.width + ", " + ellipse1.height + "), (" + | 24 new BBox(0, 100, 100, 0), |
25 ellipse2.width + ", " + ellipse2.height + "), (" + | 25 new BBox(50, 50, 0, 100), |
26 ellipse3.width + ", " + ellipse3.height + ") and (" + | 26 new BBox(0, 100, 100, 0), |
27 ellipse4.width + ", " + ellipse4.height + ")"; | 27 ]; |
28 } | 28 var ellipses = document.getElementsByTagName('ellipse'); |
29 </script> | 29 for (var i = 0, length = ellipses.length; i < length; ++i) { |
30 </head> | 30 var ellipseBBox = ellipses[i].getBBox(); |
31 <body onload="checkBoundingBoxHasZeroValue()"> | 31 test(function() { |
32 <svg> | 32 assert_equals(ellipseBBox.x, expectedBoxes[i].x); |
33 <ellipse id="ellipse1" cx="50" cy="100" rx="0" ry="50"/> | 33 assert_equals(ellipseBBox.y, expectedBoxes[i].y); |
34 <ellipse id="ellipse2" cx="50" cy="100" rx="50" ry="0"/> | 34 assert_equals(ellipseBBox.width, expectedBoxes[i].width); |
35 <ellipse id="ellipse3" vector-effect="non-scaling-stroke" cx="50" cy
="100" rx="0" ry="50"/> | 35 assert_equals(ellipseBBox.height, expectedBoxes[i].height); |
36 <ellipse id="ellipse4" vector-effect="non-scaling-stroke" cx="50" cy
="100" rx="50" ry="0"/> | 36 }, 'Bounding box size ' + expectedBoxes[i]); |
37 </svg> | 37 } |
38 <body> | 38 </script> |
39 </html> | |
OLD | NEW |