tor-browser

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

test_general.xhtml (3791B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
      3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
      4                 type="text/css"?>
      5 
      6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      7        title="test for nsIAccessibleHyperLink interface on XUL:label elements">
      8 
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
     10 
     11  <script type="application/javascript"
     12          src="../common.js" />
     13  <script type="application/javascript"
     14          src="../role.js" />
     15  <script type="application/javascript"
     16          src="../states.js" />
     17  <script type="application/javascript"
     18          src="../events.js" />
     19 
     20  <script type="application/javascript"
     21          src="hyperlink.js" />
     22 
     23  <script type="application/javascript">
     24  <![CDATA[
     25    function testThis(aID, aAcc, aRole, aAnchorCount, aAnchorName, aURI,
     26                      aStartIndex, aEndIndex, aValid)
     27    {
     28      testRole(aID, aRole);
     29      is(aAcc.anchorCount, aAnchorCount, "Wrong number of anchors for ID "
     30         + aID + "!");
     31      is(aAcc.getAnchor(0).name, aAnchorName, "Wrong name for ID " + aID + "!");
     32      is(aAcc.getURI(0).spec, aURI, "URI wrong for ID " + aID + "!");
     33      is(aAcc.startIndex, aStartIndex, "Wrong startIndex value for ID " + aID
     34         + "!");
     35      is(aAcc.endIndex, aEndIndex, "Wrong endIndex value for ID " + aID + "!");
     36      is(aAcc.valid, aValid, "Wrong valid state for ID " + aID + "!");
     37    }
     38 
     39    var gQueue = null;
     40    function doTest()
     41    {
     42      var linkedLabelAcc = getAccessible("linkedLabel",
     43                                         [nsIAccessibleHyperLink]);
     44      testThis("linkedLabel", linkedLabelAcc, ROLE_LINK, 1,
     45               // eslint-disable-next-line @microsoft/sdl/no-insecure-url
     46               "Mozilla Foundation home", "http://www.mozilla.org/", 1, 2,
     47               true);
     48      testStates(linkedLabelAcc, STATE_LINKED, 0);
     49 
     50      var labelWithValueAcc = getAccessible("linkLabelWithValue",
     51                                            [nsIAccessibleHyperLink]);
     52      testThis("linkLabelWithValue", labelWithValueAcc, ROLE_LINK, 1,
     53               // eslint-disable-next-line @microsoft/sdl/no-insecure-url
     54               "Mozilla Foundation", "http://www.mozilla.org/", 2, 3, true,
     55               false, true);
     56      testStates(labelWithValueAcc, STATE_LINKED, 0);
     57 
     58      var normalLabelAcc = getAccessible("normalLabel");
     59      testRole(normalLabelAcc, ROLE_LABEL);
     60      is(normalLabelAcc.name, "This label should not be a link",
     61         "Wrong name for normal label!");
     62      testStates(normalLabelAcc, 0, 0, (STATE_FOCUSABLE | STATE_LINKED));
     63 
     64      //////////////////////////////////////////////////////////////////////////
     65      // Test focus
     66 
     67      gQueue = new eventQueue();
     68 
     69      gQueue.push(new focusLink("linkedLabel", true));
     70      gQueue.push(new focusLink("linkLabelWithValue", true));
     71 
     72      gQueue.invoke(); // Will call SimpleTest.finish();
     73    }
     74 
     75    SimpleTest.waitForExplicitFinish();
     76    addA11yLoadEvent(doTest);
     77  ]]>
     78  </script>
     79 
     80  <body xmlns="http://www.w3.org/1999/xhtml">
     81    <a target="_blank"
     82       href="https://bugzilla.mozilla.org/show_bug.cgi?id=421066"
     83       title="Implement Mochitests for the nsIAccessibleHyperLink interface on XUL:label elements">
     84      Mozilla Bug 421066
     85    </a>
     86    <p id="display"></p>
     87    <div id="content" style="display: none">
     88    </div>
     89    <pre id="test">
     90    </pre>
     91  </body>
     92 
     93  <label id="linkedLabel" href="http://www.mozilla.org/" is="text-link">
     94    Mozilla Foundation home</label>
     95  <label id="linkLabelWithValue" value="Mozilla Foundation" is="text-link"
     96   href="http://www.mozilla.org/" />
     97  <label id="normalLabel" value="This label should not be a link" />
     98 </window>