1 <html xmlns='http://www.w3.org/
1999/xhtml'
>
22 <p>Tests for WK80423 - Make sure hit testing works properly on stroked ellipses with non-scaling stroke.
</p>
23 <p>On success, you will see a series of
"PASS" messages and no
"FAIL" messages.
</p>
24 <pre id=
"console"></pre>
26 <svg id=
"svgRoot" width=
"400px" height=
"400px" viewBox=
"0 0 400 400" xmlns=
"http://www.w3.org/2000/svg">
27 <g transform=
"scale(2)">
28 <ellipse id=
"ellipse" cx=
"75" cy=
"75" rx=
"100" ry=
"50" vector-effect=
"non-scaling-stroke"/>
33 if (window
.testRunner
)
34 testRunner
.dumpAsText();
36 var resultString
= "";
37 var ellipseElement
= document
.getElementById("ellipse");
39 var pointsInEllipse
= [
45 var pointsNotInEllipse
= [
50 var pointsOnEllipseStroke
= [
51 {x
: 275, y
: 250}, // outer stroke
52 {x
: 300, y
: 200} // inner stroke
55 var pointsNotOnEllipseStroke
= [
56 {x
: 375, y
: 375}, // outside ellipse
57 {x
: 0, y
: 0}, // outside ellipse
58 {x
: 150, y
: 150} // inside ellipse
61 ellipseElement
.style
.setProperty("pointer-events", "visibleFill"); // only capture events on the fill
62 pointsInEllipse
.forEach( function(point
) {
63 var pass
= (ellipseElement
== document
.elementFromPoint(point
.x
, point
.y
));
64 resultString
+= ((pass
) ? "PASS" : "FAIL") + " ellipse contains point at (" + point
.x
+ ", " + point
.y
+ ")\n";
66 pointsNotInEllipse
.forEach( function(point
) {
67 var pass
= (ellipseElement
!= document
.elementFromPoint(point
.x
, point
.y
));
68 resultString
+= ((pass
) ? "PASS" : "FAIL") + " ellipse does not contain point at (" + point
.x
+ ", " + point
.y
+ ")\n";
71 ellipseElement
.style
.setProperty("pointer-events", "visibleStroke"); // only capture events on the stroke
72 pointsOnEllipseStroke
.forEach( function(point
) {
73 var pass
= (ellipseElement
== document
.elementFromPoint(point
.x
, point
.y
));
74 resultString
+= ((pass
) ? "PASS" : "FAIL") + " ellipse stroke contains point at (" + point
.x
+ ", " + point
.y
+ ")\n";
76 pointsNotOnEllipseStroke
.forEach( function(point
) {
77 var pass
= (ellipseElement
!= document
.elementFromPoint(point
.x
, point
.y
));
78 resultString
+= ((pass
) ? "PASS" : "FAIL") + " ellipse stroke does not contain point at (" + point
.x
+ ", " + point
.y
+ ")\n";
80 document
.getElementById("console").innerHTML
= resultString
;