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 circ
le --> | 3 <script src="../../resources/testharnessreport.js"></script> |
4 <head> | 4 <title>SVG bounding boxes are valid for a zero-width or zero-height circle</titl
e> |
5 <script type="text/javascript"> | 5 <svg height="0"> |
6 function checkBoundingBoxHasZeroValue() { | 6 <circle cx="300" cy="300" r="50"/> |
7 if (window.testRunner) | 7 <circle cx="300" cy="300" r="0"/> |
8 window.testRunner.dumpAsText(); | 8 <circle vector-effect="non-scaling-stroke" cx="300" cy="300" r="50"/> |
9 var circle1 = document.getElementById('circle1').getBBox(); | 9 <circle vector-effect="non-scaling-stroke" cx="300" cy="300" r="0"/> |
10 var circle2 = document.getElementById('circle2').getBBox(); | 10 </svg> |
11 var circle3 = document.getElementById('circle3').getBBox(); | 11 <script> |
12 var circle4 = document.getElementById('circle4').getBBox(); | 12 BBox = function(x,y,w,h) { |
13 var results = "FAIL"; | 13 this.x = x; |
14 if (circle1.width == 100 && | 14 this.y = y; |
15 circle1.height == 100 && | 15 this.width = w; |
16 circle2.width == 0 && | 16 this.height = h; |
17 circle2.height == 0 && | 17 }; |
18 circle3.width == 100 && | 18 BBox.prototype.toString = function() { |
19 circle3.height == 100 && | 19 return this.x + "," + this.y + "," + this.width + "," + this.height; |
20 circle4.width == 0 && | 20 }; |
21 circle4.height == 0) | 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(250, 250, 100, 100), |
24 circle1.width + ", " + circle1.height + "), (" + | 24 new BBox(300, 300, 0, 0), |
25 circle2.width + ", " + circle2.height + "), (" + | 25 new BBox(250, 250, 100, 100), |
26 circle3.width + ", " + circle3.height + ") and (" + | 26 new BBox(300, 300, 0, 0), |
27 circle4.width + ", " + circle4.height + ")"; | 27 ]; |
28 } | 28 var circles = document.getElementsByTagName('circle'); |
29 </script> | 29 for (var i = 0, length = circles.length; i < length; ++i) { |
30 </head> | 30 var circleBBox = circles[i].getBBox(); |
31 <body onload="checkBoundingBoxHasZeroValue()"> | 31 test(function() { |
32 <svg> | 32 assert_equals(circleBBox.x, expectedBoxes[i].x); |
33 <circle id="circle1" cx="300" cy="300" r="50"/> | 33 assert_equals(circleBBox.y, expectedBoxes[i].y); |
34 <circle id="circle2" cx="300" cy="300" r="0"/> | 34 assert_equals(circleBBox.width, expectedBoxes[i].width); |
35 <circle id="circle3" vector-effect="non-scaling-stroke" cx="300" cy=
"300" r="50"/> | 35 assert_equals(circleBBox.height, expectedBoxes[i].height); |
36 <circle id="circle4" vector-effect="non-scaling-stroke" cx="300" cy=
"300" r="0"/> | 36 }, 'Bounding box size ' + expectedBoxes[i]); |
37 </svg> | 37 } |
38 <body> | 38 </script> |
39 </html> | |
OLD | NEW |