Skip to content

Truly independent web browser

Tests: Add a test for hit testing SVG image elements

Andreas Klingb870999ceb64
diff --git a/Tests/LibWeb/Text/expected/SVG/image-element-hit-test.txt b/Tests/LibWeb/Text/expected/SVG/image-element-hit-test.txt
new file mode 100644
index 00000000000..cb6e6f86735
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/SVG/image-element-hit-test.txt
@@ -0,0 +1,3 @@
+(30, 20): svg
+(130, 20): svg
+(230, 20): svg
diff --git a/Tests/LibWeb/Text/input/SVG/image-element-hit-test.html b/Tests/LibWeb/Text/input/SVG/image-element-hit-test.html
new file mode 100644
index 00000000000..4ecda9fae0a
--- /dev/null
+++ b/Tests/LibWeb/Text/input/SVG/image-element-hit-test.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<style>
+ body { margin: 0; }
+</style>
+<svg id="svg" width="300" height="100">
+ <image id="image" x="10" y="10" width="50" height="30" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 30'><rect width='50' height='30' fill='blue'/></svg>"/>
+ <image id="hidden" x="110" y="10" width="50" height="30" visibility="hidden" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 30'><rect width='50' height='30' fill='blue'/></svg>"/>
+ <image id="hidden-all" x="210" y="10" width="50" height="30" visibility="hidden" pointer-events="all" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 30'><rect width='50' height='30' fill='blue'/></svg>"/>
+</svg>
+<script src="../include.js"></script>
+<script>
+ test(() => {
+ for (const [x, y] of [[30, 20], [130, 20], [230, 20]]) {
+ const element = document.elementFromPoint(x, y);
+ println(`(${x}, ${y}): ${element.id}`);
+ }
+ });
+</script>