summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/svg/struct
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/svg/struct')
-rw-r--r--testing/web-platform/tests/svg/struct/scripted/svg-checkIntersection-002.svg40
-rw-r--r--testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-002.svg2
-rw-r--r--testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-005.svg22
-rw-r--r--testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-006.svg29
4 files changed, 92 insertions, 1 deletions
diff --git a/testing/web-platform/tests/svg/struct/scripted/svg-checkIntersection-002.svg b/testing/web-platform/tests/svg/struct/scripted/svg-checkIntersection-002.svg
new file mode 100644
index 0000000000..1ff1f7829f
--- /dev/null
+++ b/testing/web-platform/tests/svg/struct/scripted/svg-checkIntersection-002.svg
@@ -0,0 +1,40 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml">
+ <title>checkIntersection()</title>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/struct.html#__svg__SVGSVGElement__checkIntersection"/>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+
+ <g id="g_outer">
+ <g id="g_inner_top">
+ <rect id="r_top_left" width="50" height="50"/>
+ <rect x="50" width="50" height="50"/>
+ </g>
+ <g transform="translate(0, 50)">
+ <rect width="50" height="50"/>
+ <rect x="50" width="50" height="50"/>
+ </g>
+ </g>
+ <script>
+ function makeRect(x, y, width, height) {
+ const svg = document.documentElement;
+ return Object.assign(svg.createSVGRect(), {x, y, width, height});
+ }
+ test(t => {
+ [
+ { element: 'r_top_left', rect: [10, 10, 10, 10], expected: true },
+ { element: 'r_top_left', rect: [10, 10, 80, 10], expected: true },
+ { element: 'r_top_left', rect: [60, 10, 10, 10], expected: false },
+ { element: 'g_inner_top', rect: [10, 10, 80, 10], expected: true },
+ { element: 'g_inner_top', rect: [60, 10, 10, 10], expected: false },
+ { element: 'g_outer', rect: [10, 10, 80, 10], expected: false },
+ { element: 'g_outer', rect: [10, 10, 80, 80], expected: true },
+ ].forEach(testcase => {
+ const element = document.getElementById(testcase.element);
+ const rect = makeRect(...testcase.rect);
+ const svg = document.documentElement;
+ assert_equals(svg.checkIntersection(element, rect), testcase.expected,
+ `${document.title}, element ${testcase.element} rect ${testcase.rect}`);
+ });
+ });
+ </script>
+</svg>
diff --git a/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-002.svg b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-002.svg
index c2c1f8e425..dd30943569 100644
--- a/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-002.svg
+++ b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-002.svg
@@ -10,7 +10,7 @@
r.x = 0;
r.y = 0;
r.width = 100;
- r.height = 100;
+ r.height = 99.9;
assert_equals(testSVG.getIntersectionList(r, testSVG).length, 1);
});
diff --git a/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-005.svg b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-005.svg
new file mode 100644
index 0000000000..717c15eef5
--- /dev/null
+++ b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-005.svg
@@ -0,0 +1,22 @@
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <title>getIntersectionList() on element with intersecting bounding box</title>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/struct.html#__svg__SVGSVGElement__getIntersectionList"/>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+
+ <rect id="e0" x="110" y="100" width="100" height="100" fill="red"/>
+ <rect id="e1" x="160" y="130" width="40" height="40" fill="green"/>
+ <path id="e2" stroke="blue" fill="none" stroke-width="2" d="M100 200 120 110 220 100"/>
+
+ <script>
+test(t => {
+ const svg = document.documentElement;
+ const queryRect = document.getElementById('e1').getBBox();
+
+ const list = svg.getIntersectionList(queryRect, null);
+ const result = Array.from(list).map(e => e.id).sort();
+ assert_array_equals(result, ['e0', 'e1']);
+});
+ </script>
+</svg>
diff --git a/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-006.svg b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-006.svg
new file mode 100644
index 0000000000..a7b9465013
--- /dev/null
+++ b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-006.svg
@@ -0,0 +1,29 @@
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <title>getIntersectionList() with &lt;use></title>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/struct.html#__svg__SVGSVGElement__getIntersectionList"/>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+
+ <defs>
+ <g id="conn">
+ <circle cx="0" cy="0" r="20"/>
+ </g>
+ </defs>
+ <circle cx="65" cy="50" r="20" fill="blue"/>
+ <use href="#conn" x="50" y="50" fill="red"/>
+
+ <script>
+ function getMatchingLocalNames(x, y) {
+ const svg = document.documentElement;
+ const rect = Object.assign(svg.createSVGRect(), {x, y, width: 1, height: 1});
+ const elems = svg.getIntersectionList(rect, null);
+ return Array.from(elems).map(e => e.localName).sort();
+ }
+
+ test(t => {
+ assert_array_equals(getMatchingLocalNames(50, 60), ['circle', 'use']);
+ assert_array_equals(getMatchingLocalNames(0, 0), []);
+ });
+ </script>
+</svg>