summaryrefslogtreecommitdiffstats
path: root/dom/svg/test/test_a_href_01.xhtml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/svg/test/test_a_href_01.xhtml
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/svg/test/test_a_href_01.xhtml')
-rw-r--r--dom/svg/test/test_a_href_01.xhtml96
1 files changed, 96 insertions, 0 deletions
diff --git a/dom/svg/test/test_a_href_01.xhtml b/dom/svg/test/test_a_href_01.xhtml
new file mode 100644
index 0000000000..a1ff8d7227
--- /dev/null
+++ b/dom/svg/test/test_a_href_01.xhtml
@@ -0,0 +1,96 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=620295
+https://bugzilla.mozilla.org/show_bug.cgi?id=1245751
+-->
+<head>
+ <title>Test that activating SVG 'a' elements navigate to their xlink:href or href</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=620295">Mozilla Bug 620295</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1245751">Mozilla Bug 1245751</a>
+<p id="display"></p>
+<pre id="test">
+<script class="testbody" type="text/javascript"><![CDATA[
+
+SimpleTest.waitForExplicitFinish();
+
+var testCount = 7;
+var didWindowLoad = false;
+var frameLoadCount = 0;
+var navigationCount = 0;
+
+function endsWith(s1, s2) {
+ s1 = String(s1);
+ return s1.length >= s2.length && s1.substring(s1.length - s2.length) == s2;
+}
+
+function windowLoaded() {
+ didWindowLoad = true;
+ doNavigationIfReady();
+}
+
+function frameLoaded() {
+ frameLoadCount++;
+ doNavigationIfReady();
+}
+
+function doNavigationIfReady() {
+ if (didWindowLoad && frameLoadCount == testCount) {
+ doNavigation();
+ }
+}
+
+function doNavigation() {
+ // Test clicking on an unmodified <a>.
+ doNavigationTest(1, "a_href_helper_01.svg");
+ // Test clicking on an <a> whose xlink:href is modified by assigning to href.baseVal.
+ doNavigationTest(2, "a_href_helper_02_03.svg", function(a) { a.href.baseVal = "a_href_destination.svg"; });
+ // Test clicking on an <a> whose xlink:href is modified by a setAttributeNS call.
+ doNavigationTest(3, "a_href_helper_02_03.svg", function(a) { a.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "a_href_destination.svg"); });
+ // Test clicking on an <a> whose xlink:href is modified by animation.
+ doNavigationTest(4, "a_href_helper_04.svg");
+ // Test clicking on an unmodified <a> with both href and xlink:href.
+ doNavigationTest(5, "a_href_helper_05.svg");
+ // Test clicking on an <a> whose href is modified by a setAttribute call.
+ doNavigationTest(6, "a_href_helper_06.svg", function(a) { a.setAttribute("href", "a_href_destination.svg"); });
+ // Test clicking on an <a> whose href is modified by animation.
+ doNavigationTest(7, "a_href_helper_07.svg");
+}
+
+function doNavigationTest(testNumber, initialHref, f) {
+ var iframe = document.getElementById("iframe" + testNumber);
+ var a = iframe.contentDocument.getElementById("a");
+ ok(endsWith(iframe.contentWindow.location, initialHref), "Initial href of test " + testNumber);
+ is("pointer", window.getComputedStyle(a).getPropertyValue("cursor"), "expected pointer cursor");
+ iframe.onload = function() {
+ ok(endsWith(iframe.contentWindow.location, "a_href_destination.svg"), "Final href of test " + testNumber);
+ if (++navigationCount == testCount) {
+ SimpleTest.finish();
+ }
+ };
+ if (f) {
+ f(a);
+ }
+ sendMouseEvent({type: "click"}, a);
+}
+
+window.onload = windowLoaded;
+
+]]></script>
+</pre>
+<div id="content" style="visibility: hidden">
+<!-- These must come after frameLoaded is defined -->
+<iframe id="iframe1" src="a_href_helper_01.svg" onload="frameLoaded()"></iframe>
+<iframe id="iframe2" src="a_href_helper_02_03.svg" onload="frameLoaded()"></iframe>
+<iframe id="iframe3" src="a_href_helper_02_03.svg" onload="frameLoaded()"></iframe>
+<iframe id="iframe4" src="a_href_helper_04.svg" onload="frameLoaded()"></iframe>
+<iframe id="iframe5" src="a_href_helper_05.svg" onload="frameLoaded()"></iframe>
+<iframe id="iframe6" src="a_href_helper_06.svg" onload="frameLoaded()"></iframe>
+<iframe id="iframe7" src="a_href_helper_07.svg" onload="frameLoaded()"></iframe>
+</div>
+</body>
+</html>