1<!DOCTYPE html>
2<html>
3<head>
4<title>Document::nodesFromRect : Rect-based hit-testing on SVG elements - bug ?</title>
5<style type="text/css">
6 #sandbox {
7 position: absolute;
8 left: 0px;
9 top: 0px;
10 width: 600px;
11 height: 800px;
12 }
13 .svg {
14 width: 40px;
15 height: 20px;
16 margin: 10px;
17 padding: 2px;
18 box-sizing: border-box;
19 }
20</style>
21<script src="../js/resources/js-test-pre.js"></script>
22<script src="resources/nodesFromRect.js"></script>
23</head>
24
25<body>
26 <div id=sandbox>
27 <div class=svg id=div1>
28 <svg id=svg1 height=16 xmlns="http://www.w3.org/2000/svg">
29 <circle id="red" cx="8" cy="8" r="5" fill="red" />
30 </svg>
31 </div>
32 <div class=svg id=div2>
33 <svg id=svg2 height=16 xmlns="http://www.w3.org/2000/svg">
34 <circle id="yellow" cx="8" cy="8" r="5" fill="yellow" />
35 </svg>
36 </div>
37 <div class=svg id=div3>
38 <svg id=svg3 height=16 xmlns="http://www.w3.org/2000/svg">
39 <circle id="green" cx="8" cy="8" r="5" fill="green" />
40 </svg>
41 </div>
42 </div>
43
44 <script>
45 function runTest()
46 {
47 description(document.title);
48 var e = {};
49
50 // Set up shortcut access to elements
51 ['sandbox', 'div1', 'div2', 'div3', 'div4',
52 'svg1', 'svg2', 'svg3', 'svg4',
53 'red', 'yellow', 'green'].forEach(function(a) {
54 e[a] = document.getElementById(a);
55 });
56
57 window.scrollTo(0, 0);
58
59 debug('Check area hits fully inside SVG element');
60 check(20, 20, 4, 4, 4, 4, [e.red]);
61 check(20, 52, 4, 4, 4, 4, [e.yellow]);
62 check(18, 80, 4, 4, 4, 4, [e.green]);
63 check(14, 14, 2, 2, 2, 2, [e.svg1]);
64
65 debug('\nThe following tests will likely FAIL and will need to be updated once rect-based')
66 debug('hit tests are supported inside SVG elements:\n');
67
68 debug('Check area hits overlapping SVG element');
69 check(12, 12, 2, 2, 2, 2, [e.svg1, e.div1]);
70 check(6, 50, 5, 20, 5, 5, [e.svg2, e.div2, e.sandbox]);
71
72 debug('Check area hits across SVG elements');
73 check(20, 30, 20, 10, 30, 10, [e.svg2, e.div2, e.svg1, e.div1, e.sandbox]);
74
75 debug('');
76 }
77
78 runTest();
79 </script>
80
81 <p id='description'></p>
82 <span id="console"></span>
83 <script src="../js/resources/js-test-post.js"></script>
84</body>
85</html>
86