1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/hyperlink/test_general.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 1.7 + type="text/css"?> 1.8 + 1.9 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.10 + title="test for nsIAccessibleHyperLink interface on XUL:label elements"> 1.11 + 1.12 + <script type="application/javascript" 1.13 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 1.14 + 1.15 + <script type="application/javascript" 1.16 + src="../common.js" /> 1.17 + <script type="application/javascript" 1.18 + src="../role.js" /> 1.19 + <script type="application/javascript" 1.20 + src="../states.js" /> 1.21 + <script type="application/javascript" 1.22 + src="../events.js" /> 1.23 + 1.24 + <script type="application/javascript" 1.25 + src="hyperlink.js" /> 1.26 + 1.27 + <script type="application/javascript"> 1.28 + <![CDATA[ 1.29 + function testThis(aID, aAcc, aRole, aAnchorCount, aAnchorName, aURI, 1.30 + aStartIndex, aEndIndex, aValid) 1.31 + { 1.32 + testRole(aID, aRole); 1.33 + is(aAcc.anchorCount, aAnchorCount, "Wrong number of anchors for ID " 1.34 + + aID + "!"); 1.35 + is(aAcc.getAnchor(0).name, aAnchorName, "Wrong name for ID " + aID + "!"); 1.36 + is(aAcc.getURI(0).spec, aURI, "URI wrong for ID " + aID + "!"); 1.37 + is(aAcc.startIndex, aStartIndex, "Wrong startIndex value for ID " + aID 1.38 + + "!"); 1.39 + is(aAcc.endIndex, aEndIndex, "Wrong endIndex value for ID " + aID + "!"); 1.40 + is(aAcc.valid, aValid, "Wrong valid state for ID " + aID + "!"); 1.41 + } 1.42 + 1.43 + var gQueue = null; 1.44 + function doTest() 1.45 + { 1.46 + var linkedLabelAcc = getAccessible("linkedLabel", 1.47 + [nsIAccessibleHyperLink]); 1.48 + testThis("linkedLabel", linkedLabelAcc, ROLE_LINK, 1, 1.49 + "Mozilla Foundation home", "http://www.mozilla.org/", 1, 2, 1.50 + true); 1.51 + testStates(linkedLabelAcc, STATE_LINKED, 0); 1.52 + 1.53 + var labelWithValueAcc = getAccessible("linkLabelWithValue", 1.54 + [nsIAccessibleHyperLink]); 1.55 + testThis("linkLabelWithValue", labelWithValueAcc, ROLE_LINK, 1, 1.56 + "Mozilla Foundation", "http://www.mozilla.org/", 2, 3, true, 1.57 + false, true); 1.58 + testStates(labelWithValueAcc, STATE_LINKED, EXT_STATE_HORIZONTAL); 1.59 + 1.60 + var normalLabelAcc = getAccessible("normalLabel"); 1.61 + testRole(normalLabelAcc, ROLE_LABEL); 1.62 + is(normalLabelAcc.name, "This label should not be a link", 1.63 + "Wrong name for normal label!"); 1.64 + testStates(normalLabelAcc, 0, 0, (STATE_FOCUSABLE | STATE_LINKED)); 1.65 + 1.66 + ////////////////////////////////////////////////////////////////////////// 1.67 + // Test focus 1.68 + 1.69 + gQueue = new eventQueue(); 1.70 + 1.71 + gQueue.push(new focusLink("linkedLabel", true)); 1.72 + gQueue.push(new focusLink("linkLabelWithValue", true)); 1.73 + 1.74 + gQueue.invoke(); // Will call SimpleTest.finish(); 1.75 + } 1.76 + 1.77 + SimpleTest.waitForExplicitFinish(); 1.78 + addA11yLoadEvent(doTest); 1.79 + ]]> 1.80 + </script> 1.81 + 1.82 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.83 + <a target="_blank" 1.84 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=421066" 1.85 + title="Implement Mochitests for the nsIAccessibleHyperLink interface on XUL:label elements"> 1.86 + Mozilla Bug 421066 1.87 + </a> 1.88 + <p id="display"></p> 1.89 + <div id="content" style="display: none"> 1.90 + </div> 1.91 + <pre id="test"> 1.92 + </pre> 1.93 + </body> 1.94 + 1.95 + <label id="linkedLabel" class="text-link" href="http://www.mozilla.org/"> 1.96 + Mozilla Foundation home</label> 1.97 + <label id="linkLabelWithValue" value="Mozilla Foundation" class="text-link" 1.98 + href="http://www.mozilla.org/" /> 1.99 + <label id="normalLabel" value="This label should not be a link" /> 1.100 +</window>