1 <html xmlns=
"http://www.w3.org/1999/xhtml">
3 https://bugzilla.mozilla.org/show_bug.cgi?id=620295
4 https://bugzilla.mozilla.org/show_bug.cgi?id=1245751
7 <title>Test that activating SVG 'a' elements navigate to their xlink:href or href
</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=620295">Mozilla Bug
620295</a>
14 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1245751">Mozilla Bug
1245751</a>
17 <script class=
"testbody" type=
"text/javascript"><![CDATA[
19 SimpleTest.waitForExplicitFinish();
22 var didWindowLoad = false;
23 var frameLoadCount =
0;
24 var navigationCount =
0;
26 function endsWith(s1, s2) {
28 return s1.length
>= s2.length && s1.substring(s1.length - s2.length) == s2;
31 function windowLoaded() {
33 doNavigationIfReady();
36 function frameLoaded() {
38 doNavigationIfReady();
41 function doNavigationIfReady() {
42 if (didWindowLoad && frameLoadCount == testCount) {
47 function doNavigation() {
48 // Test clicking on an unmodified
<a>.
49 doNavigationTest(
1,
"a_href_helper_01.svg");
50 // Test clicking on an
<a> whose xlink:href is modified by assigning to href.baseVal.
51 doNavigationTest(
2,
"a_href_helper_02_03.svg", function(a) { a.href.baseVal =
"a_href_destination.svg"; });
52 // Test clicking on an
<a> whose xlink:href is modified by a setAttributeNS call.
53 doNavigationTest(
3,
"a_href_helper_02_03.svg", function(a) { a.setAttributeNS(
"http://www.w3.org/1999/xlink",
"xlink:href",
"a_href_destination.svg"); });
54 // Test clicking on an
<a> whose xlink:href is modified by animation.
55 doNavigationTest(
4,
"a_href_helper_04.svg");
56 // Test clicking on an unmodified
<a> with both href and xlink:href.
57 doNavigationTest(
5,
"a_href_helper_05.svg");
58 // Test clicking on an
<a> whose href is modified by a setAttribute call.
59 doNavigationTest(
6,
"a_href_helper_06.svg", function(a) { a.setAttribute(
"href",
"a_href_destination.svg"); });
60 // Test clicking on an
<a> whose href is modified by animation.
61 doNavigationTest(
7,
"a_href_helper_07.svg");
64 function doNavigationTest(testNumber, initialHref, f) {
65 var iframe = document.getElementById(
"iframe" + testNumber);
66 var a = iframe.contentDocument.getElementById(
"a");
67 ok(endsWith(iframe.contentWindow.location, initialHref),
"Initial href of test " + testNumber);
68 is(
"pointer", window.getComputedStyle(a).getPropertyValue(
"cursor"),
"expected pointer cursor");
69 iframe.onload = function() {
70 ok(endsWith(iframe.contentWindow.location,
"a_href_destination.svg"),
"Final href of test " + testNumber);
71 if (++navigationCount == testCount) {
78 sendMouseEvent({type:
"click"}, a);
81 window.onload = windowLoaded;
85 <div id=
"content" style=
"visibility: hidden">
86 <!-- These must come after frameLoaded is defined -->
87 <iframe id=
"iframe1" src=
"a_href_helper_01.svg" onload=
"frameLoaded()"></iframe>
88 <iframe id=
"iframe2" src=
"a_href_helper_02_03.svg" onload=
"frameLoaded()"></iframe>
89 <iframe id=
"iframe3" src=
"a_href_helper_02_03.svg" onload=
"frameLoaded()"></iframe>
90 <iframe id=
"iframe4" src=
"a_href_helper_04.svg" onload=
"frameLoaded()"></iframe>
91 <iframe id=
"iframe5" src=
"a_href_helper_05.svg" onload=
"frameLoaded()"></iframe>
92 <iframe id=
"iframe6" src=
"a_href_helper_06.svg" onload=
"frameLoaded()"></iframe>
93 <iframe id=
"iframe7" src=
"a_href_helper_07.svg" onload=
"frameLoaded()"></iframe>