Skip to content

Truly independent web browser

LibWeb: Add SVG link navigation fallback coverage

Andreas Kling7c365f3424f4
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index b75772d014a..d2e995773c4 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -175,6 +175,9 @@ Text/input/wpt-import/html/browsers/history/the-history-interface/history_replac
Text/input/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.html
Text/input/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.html
+; Follows SVG links to root-relative URLs, which need an HTTP origin.
+Text/input/SVG/svg-link-xlink-navigation.html
+
; Compares the URLs of HTTP documents, which need an HTTP origin.
Text/input/wpt-import/html/browsers/history/the-location-interface/location-encoding-parse.html
diff --git a/Tests/LibWeb/Text/expected/SVG/svg-link-xlink-navigation.txt b/Tests/LibWeb/Text/expected/SVG/svg-link-xlink-navigation.txt
new file mode 100644
index 00000000000..2d0922e4535
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/SVG/svg-link-xlink-navigation.txt
@@ -0,0 +1,3 @@
+href=null:
+href="#modern": #modern
+href="":
diff --git a/Tests/LibWeb/Text/input/SVG/svg-link-xlink-navigation.html b/Tests/LibWeb/Text/input/SVG/svg-link-xlink-navigation.html
new file mode 100644
index 00000000000..18053f5d660
--- /dev/null
+++ b/Tests/LibWeb/Text/input/SVG/svg-link-xlink-navigation.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script>
+ asyncTest(async done => {
+ const base = document.createElement("base");
+ base.href = "../wpt-import/common/blank.html";
+ document.head.append(base);
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+ document.body.append(svg);
+ for (const href of [null, "#modern", ""]) {
+ const frame = document.createElement("iframe");
+ frame.name = "destination";
+ const initiallyLoaded = new Promise(resolve => frame.onload = resolve);
+ document.body.append(frame);
+ await initiallyLoaded;
+ const link = document.createElementNS(svg.namespaceURI, "a");
+ link.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#legacy");
+ if (href !== null)
+ link.setAttribute("href", href);
+ link.setAttribute("target", frame.name);
+ const child = document.createElement("span");
+ link.append(child);
+ svg.append(link);
+ const navigated = new Promise(resolve => frame.onload = resolve);
+ child.click();
+ await navigated;
+ println(`href=${JSON.stringify(href)}: ${frame.contentWindow.location.hash}`);
+ link.remove();
+ frame.remove();
+ }
+ done();
+ });
+</script>