tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_a_href_01.xhtml (3793B)


      1 <html xmlns="http://www.w3.org/1999/xhtml">
      2 <!--
      3 https://bugzilla.mozilla.org/show_bug.cgi?id=620295
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1245751
      5 -->
      6 <head>
      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" />
     11 </head>
     12 <body>
     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>
     15 <p id="display"></p>
     16 <pre id="test">
     17 <script class="testbody" type="text/javascript"><![CDATA[
     18 
     19 SimpleTest.waitForExplicitFinish();
     20 
     21 var testCount = 7;
     22 var didWindowLoad = false;
     23 var frameLoadCount = 0;
     24 var navigationCount = 0;
     25 
     26 function endsWith(s1, s2) {
     27  s1 = String(s1);
     28  return s1.length >= s2.length && s1.substring(s1.length - s2.length) == s2;
     29 }
     30 
     31 function windowLoaded() {
     32  didWindowLoad = true;
     33  doNavigationIfReady();
     34 }
     35 
     36 function frameLoaded() {
     37  frameLoadCount++;
     38  doNavigationIfReady();
     39 }
     40 
     41 function doNavigationIfReady() {
     42  if (didWindowLoad && frameLoadCount == testCount) {
     43    doNavigation();
     44  }
     45 }
     46 
     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");
     62 }
     63 
     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) {
     72      SimpleTest.finish();
     73    }
     74  };
     75  if (f) {
     76    f(a);
     77  }
     78  sendMouseEvent({type: "click"}, a);
     79 }
     80 
     81 window.onload = windowLoaded;
     82 
     83 ]]></script>
     84 </pre>
     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>
     94 </div>
     95 </body>
     96 </html>