6 border:
1px solid black;
12 background-color: green;
14 -webkit-clip-path: url(#c1);
19 background-color: red;
27 <clipPath id=
"c1" clipPathUnits=
"objectBoundingBox">
28 <circle cx=
"0.5" cy=
"0.5" r=
"0.2">
33 <div id=
"reference-box"></div>
36 <script src=
"../../resources/js-test.js"></script>
38 description("Test that hit-test work with clip-path using svg reference");
41 var clipElement
= document
.getElementById('clip');
42 var referenceElement
= document
.getElementById('reference-box');
43 var resultString
= "";
45 var circleBoundingRect
= referenceElement
.getBoundingClientRect();
46 var center_x
= (circleBoundingRect
.left
+ circleBoundingRect
.right
) / 2;
47 var center_y
= (circleBoundingRect
.top
+ circleBoundingRect
.bottom
) / 2;
49 {x
: center_x
, y
: center_y
},
50 {x
: center_x
- 5, y
: center_y
- 5},
51 {x
: center_x
+ 5, y
: center_y
+ 5},
52 {x
: center_x
- 5, y
: center_y
+ 5},
53 {x
: center_x
+ 5, y
: center_y
- 5},
56 var pointsNotInPath
= [
57 {x
: circleBoundingRect
.left
,
58 y
: circleBoundingRect
.top
},
59 {x
: circleBoundingRect
.left
- 1,
60 y
: circleBoundingRect
.top
- 1},
61 {x
: circleBoundingRect
.left
+ 1,
62 y
: circleBoundingRect
.top
+ 1},
65 pointsInPath
.forEach( function(point
) {
66 var pass
= (clipElement
== document
.elementFromPoint(point
.x
, point
.y
));
67 resultString
+= ((pass
) ? "PASS" : "FAIL") + " path contains point at (" + point
.x
+ ", " + point
.y
+ ")\n";
70 pointsNotInPath
.forEach( function(point
) {
71 var pass
= (clipElement
!= document
.elementFromPoint(point
.x
, point
.y
));
72 resultString
+= ((pass
) ? "PASS" : "FAIL") + " path does not contain point at (" + point
.x
+ ", " + point
.y
+ ")\n";