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