| 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 rect
--> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <head> | 4 <title>SVG bounding boxes are valid for a zero-width or zero-height rect</title> |
| 5 <script type="text/javascript"> | 5 <svg height="0"> |
| 6 function checkBoundingBoxHasZeroValue() { | 6 <rect height="100" width="0"/> |
| 7 if (window.testRunner) | 7 <rect height="0" width="100"/> |
| 8 window.testRunner.dumpAsText(); | 8 <rect vector-effect="non-scaling-stroke" height="100" width="0"/> |
| 9 var rectBox1 = document.getElementById('rect1').getBBox(); | 9 <rect vector-effect="non-scaling-stroke" height="0" width="100"/> |
| 10 » » var rectBox2 = document.getElementById('rect2').getBBox(); | 10 <rect rx="10" vector-effect="non-scaling-stroke" height="100" width="0"/> |
| 11 » » var rectBox3 = document.getElementById('rect3').getBBox(); | 11 <rect rx="10" vector-effect="non-scaling-stroke" height="0" width="100"/> |
| 12 » » var rectBox4 = document.getElementById('rect4').getBBox(); | 12 <rect ry="10" vector-effect="non-scaling-stroke" height="100" width="0"/> |
| 13 var results = "FAIL"; | 13 <rect ry="10" vector-effect="non-scaling-stroke" height="0" width="100"/> |
| 14 if (rectBox1.height == 100 && rectBox1.width == 0 && | 14 <rect rx="10" ry="10" vector-effect="non-scaling-stroke" height="100" width="0
"/> |
| 15 rectBox2.height == 0 && rectBox2.width == 100 && | 15 <rect rx="10" ry="10" vector-effect="non-scaling-stroke" height="0" width="100
"/> |
| 16 rectBox3.height == 100 && rectBox3.width == 0 && | 16 <rect x="100" y="200" height="100" width="0"/> |
| 17 rectBox4.height == 0 && rectBox4.width == 100) | 17 <rect x="100" y="200" height="0" width="100"/> |
| 18 results = "PASS"; | 18 <rect x="100" y="200" vector-effect="non-scaling-stroke" height="100" width="0
"/> |
| 19 document.body.innerHTML = results + ", bounding box sizes are ("
+ | 19 <rect x="100" y="200" vector-effect="non-scaling-stroke" height="0" width="100
"/> |
| 20 rectBox1.width + ", " + rectBox1.height + "), (" + | 20 <rect x="100" y="200" rx="10" vector-effect="non-scaling-stroke" height="100"
width="0"/> |
| 21 rectBox2.width + ", " + rectBox2.height + "), (" + | 21 <rect x="100" y="200" rx="10" vector-effect="non-scaling-stroke" height="0" wi
dth="100"/> |
| 22 rectBox3.width + ", " + rectBox3.height + ") and (" + | 22 <rect x="100" y="200" ry="10" vector-effect="non-scaling-stroke" height="100"
width="0"/> |
| 23 rectBox4.width + ", " + rectBox4.height + ")"; | 23 <rect x="100" y="200" ry="10" vector-effect="non-scaling-stroke" height="0" wi
dth="100"/> |
| 24 } | 24 <rect x="100" y="200" rx="10" ry="10" vector-effect="non-scaling-stroke" heigh
t="100" width="0"/> |
| 25 </script> | 25 <rect x="100" y="200" rx="10" ry="10" vector-effect="non-scaling-stroke" heigh
t="0" width="100"/> |
| 26 </head> | 26 </svg> |
| 27 <body onload="checkBoundingBoxHasZeroValue()"> | 27 <script> |
| 28 <svg> | 28 BBox = function(x,y,w,h) { |
| 29 <rect id="rect1" height="100" width="0"/> | 29 this.x = x; |
| 30 </svg> | 30 this.y = y; |
| 31 » <svg> | 31 this.width = w; |
| 32 <rect id="rect2" height="0" width="100"/> | 32 this.height = h; |
| 33 » </svg> | 33 }; |
| 34 » <svg> | 34 BBox.prototype.toString = function() { |
| 35 <rect id="rect3" vector-effect="non-scaling-stroke" height="100" wid
th="0"/> | 35 return this.x + "," + this.y + "," + this.width + "," + this.height; |
| 36 » </svg> | 36 }; |
| 37 » <svg> | 37 // The order of expected sizes should equal the document order of the rects. |
| 38 <rect id="rect4" vector-effect="non-scaling-stroke" height="0" width
="100"/> | 38 var expectedBoxes = [ |
| 39 » </svg> | 39 new BBox(0, 0, 0, 100), |
| 40 <body> | 40 new BBox(0, 0, 100, 0), |
| 41 </html> | 41 new BBox(0, 0, 0, 100), |
| 42 new BBox(0, 0, 100, 0), |
| 43 new BBox(0, 0, 0, 100), |
| 44 new BBox(0, 0, 100, 0), |
| 45 new BBox(0, 0, 0, 100), |
| 46 new BBox(0, 0, 100, 0), |
| 47 new BBox(0, 0, 0, 100), |
| 48 new BBox(0, 0, 100, 0), |
| 49 new BBox(100, 200, 0, 100), |
| 50 new BBox(100, 200, 100, 0), |
| 51 new BBox(100, 200, 0, 100), |
| 52 new BBox(100, 200, 100, 0), |
| 53 new BBox(100, 200, 0, 100), |
| 54 new BBox(100, 200, 100, 0), |
| 55 new BBox(100, 200, 0, 100), |
| 56 new BBox(100, 200, 100, 0), |
| 57 new BBox(100, 200, 0, 100), |
| 58 new BBox(100, 200, 100, 0), |
| 59 ]; |
| 60 var rects = document.getElementsByTagName('rect'); |
| 61 for (var i = 0, length = rects.length; i < length; ++i) { |
| 62 var rectBBox = rects[i].getBBox(); |
| 63 test(function() { |
| 64 assert_equals(rectBBox.x, expectedBoxes[i].x); |
| 65 assert_equals(rectBBox.y, expectedBoxes[i].y); |
| 66 assert_equals(rectBBox.width, expectedBoxes[i].width); |
| 67 assert_equals(rectBBox.height, expectedBoxes[i].height); |
| 68 }, 'Bounding box size ' + expectedBoxes[i]); |
| 69 } |
| 70 </script> |
| OLD | NEW |