|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <head> |
|
4 <title>Add and remove optgroup test</title> |
|
5 <link rel="stylesheet" type="text/css" |
|
6 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
7 |
|
8 <script type="application/javascript" |
|
9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
10 |
|
11 <script type="application/javascript" |
|
12 src="../common.js"></script> |
|
13 <script type="application/javascript" |
|
14 src="../role.js"></script> |
|
15 <script type="application/javascript" |
|
16 src="../events.js"></script> |
|
17 |
|
18 <script type="application/javascript"> |
|
19 |
|
20 function addOptGroup(aID) |
|
21 { |
|
22 this.selectNode = getNode(aID); |
|
23 this.select = getAccessible(this.selectNode); |
|
24 |
|
25 this.invoke = function addOptGroup_invoke() |
|
26 { |
|
27 var optGroup = document.createElement("optgroup"); |
|
28 for (i = 0; i < 2; i++) { |
|
29 var opt = document.createElement("option"); |
|
30 opt.value = i; |
|
31 opt.text = "Option: Value " + i; |
|
32 |
|
33 optGroup.appendChild(opt); |
|
34 } |
|
35 |
|
36 this.selectNode.add(optGroup, null); |
|
37 var option = document.createElement("option"); |
|
38 this.selectNode.add(option, null); |
|
39 } |
|
40 |
|
41 this.eventSeq = [ |
|
42 new invokerChecker(EVENT_REORDER, this.select) |
|
43 ]; |
|
44 |
|
45 this.finalCheck = function addOptGroup_finalCheck() |
|
46 { |
|
47 var tree = |
|
48 { COMBOBOX: [ |
|
49 { COMBOBOX_LIST: [ |
|
50 { GROUPING: [ |
|
51 { COMBOBOX_OPTION: [ |
|
52 { TEXT_LEAF: [] } |
|
53 ] }, |
|
54 { COMBOBOX_OPTION: [ |
|
55 { TEXT_LEAF: [] } |
|
56 ] }, |
|
57 ]}, |
|
58 { COMBOBOX_OPTION: [] } |
|
59 ] } |
|
60 ] }; |
|
61 testAccessibleTree(this.select, tree); |
|
62 } |
|
63 |
|
64 this.getID = function addOptGroup_getID() |
|
65 { |
|
66 return "test optgroup's insertion into a select"; |
|
67 } |
|
68 } |
|
69 |
|
70 function removeOptGroup(aID) |
|
71 { |
|
72 this.selectNode = getNode(aID); |
|
73 this.select = getAccessible(this.selectNode); |
|
74 |
|
75 this.invoke = function removeOptGroup_invoke() |
|
76 { |
|
77 this.option1Node = this.selectNode.firstChild.firstChild; |
|
78 this.selectNode.removeChild(this.selectNode.firstChild); |
|
79 } |
|
80 |
|
81 this.eventSeq = [ |
|
82 new invokerChecker(EVENT_REORDER, this.select) |
|
83 ]; |
|
84 |
|
85 this.finalCheck = function removeOptGroup_finalCheck() |
|
86 { |
|
87 var tree = |
|
88 { COMBOBOX: [ |
|
89 { COMBOBOX_LIST: [ |
|
90 { COMBOBOX_OPTION: [] } |
|
91 ] } |
|
92 ] }; |
|
93 testAccessibleTree(this.select, tree); |
|
94 is(isAccessible(this.option1Node), false, "removed option shouldn't be accessible anymore!"); |
|
95 } |
|
96 |
|
97 this.getID = function removeOptGroup_getID() |
|
98 { |
|
99 return "test optgroup's removal from a select"; |
|
100 } |
|
101 } |
|
102 |
|
103 // gA11yEventDumpToConsole = true; |
|
104 |
|
105 function doTest() |
|
106 { |
|
107 gQueue = new eventQueue(); |
|
108 |
|
109 gQueue.push(new addOptGroup("select")); |
|
110 gQueue.push(new removeOptGroup("select")); |
|
111 |
|
112 gQueue.invoke(); // Will call SimpleTest.finish(); |
|
113 |
|
114 } |
|
115 |
|
116 SimpleTest.waitForExplicitFinish(); |
|
117 addA11yLoadEvent(doTest); |
|
118 </script> |
|
119 </head> |
|
120 <body> |
|
121 |
|
122 <a target="_blank" |
|
123 href="https://bugzilla.mozilla.org/show_bug.cgi?id=616452" |
|
124 title="Bug 616452 - Dynamically inserted select options aren't reflected in accessible tree"> |
|
125 Bug 616452</a> |
|
126 <p id="display"></p> |
|
127 <div id="content" style="display: none"></div> |
|
128 <pre id="test"> |
|
129 </pre> |
|
130 |
|
131 <select id="select"></select> |
|
132 |
|
133 <div id="debug"/> |
|
134 </body> |
|
135 </html> |