browser_treeupdate_visibility.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. 'use strict';
  5. /* global EVENT_REORDER */
  6. loadScripts({ name: 'role.js', dir: MOCHITESTS_DIR });
  7. function* testTreeOnHide(browser, accDoc, containerID, id, before, after) {
  8. let acc = findAccessibleChildByID(accDoc, containerID);
  9. testAccessibleTree(acc, before);
  10. let onReorder = waitForEvent(EVENT_REORDER, containerID);
  11. yield invokeSetStyle(browser, id, 'visibility', 'hidden');
  12. yield onReorder;
  13. testAccessibleTree(acc, after);
  14. }
  15. function* test3(browser, accessible) {
  16. let tree = {
  17. SECTION: [ // container
  18. { SECTION: [ // parent
  19. { SECTION: [ // child
  20. { TEXT_LEAF: [] }
  21. ] }
  22. ] },
  23. { SECTION: [ // parent2
  24. { SECTION: [ // child2
  25. { TEXT_LEAF: [] }
  26. ] }
  27. ] }
  28. ] };
  29. testAccessibleTree(accessible, tree);
  30. let onReorder = waitForEvent(EVENT_REORDER, 't3_container');
  31. yield ContentTask.spawn(browser, {}, () => {
  32. let doc = content.document;
  33. doc.getElementById('t3_container').style.color = 'red';
  34. doc.getElementById('t3_parent').style.visibility = 'hidden';
  35. doc.getElementById('t3_parent2').style.visibility = 'hidden';
  36. });
  37. yield onReorder;
  38. tree = {
  39. SECTION: [ // container
  40. { SECTION: [ // child
  41. { TEXT_LEAF: [] }
  42. ] },
  43. { SECTION: [ // child2
  44. { TEXT_LEAF: [] }
  45. ] }
  46. ] };
  47. testAccessibleTree(accessible, tree);
  48. }
  49. function* test4(browser, accessible) {
  50. let tree = {
  51. SECTION: [
  52. { TABLE: [
  53. { ROW: [
  54. { CELL: [ ] }
  55. ] }
  56. ] }
  57. ] };
  58. testAccessibleTree(accessible, tree);
  59. let onReorder = waitForEvent(EVENT_REORDER, 't4_parent');
  60. yield ContentTask.spawn(browser, {}, () => {
  61. let doc = content.document;
  62. doc.getElementById('t4_container').style.color = 'red';
  63. doc.getElementById('t4_child').style.visibility = 'visible';
  64. });
  65. yield onReorder;
  66. tree = {
  67. SECTION: [{
  68. TABLE: [{
  69. ROW: [{
  70. CELL: [{
  71. SECTION: [{
  72. TEXT_LEAF: []
  73. }]
  74. }]
  75. }]
  76. }]
  77. }]
  78. };
  79. testAccessibleTree(accessible, tree);
  80. }
  81. addAccessibleTask('doc_treeupdate_visibility.html', function*(browser, accDoc) {
  82. let t3Container = findAccessibleChildByID(accDoc, 't3_container');
  83. let t4Container = findAccessibleChildByID(accDoc, 't4_container');
  84. yield testTreeOnHide(browser, accDoc, 't1_container', 't1_parent', {
  85. SECTION: [{
  86. SECTION: [{
  87. SECTION: [ { TEXT_LEAF: [] } ]
  88. }]
  89. }]
  90. }, {
  91. SECTION: [ {
  92. SECTION: [ { TEXT_LEAF: [] } ]
  93. } ]
  94. });
  95. yield testTreeOnHide(browser, accDoc, 't2_container', 't2_grandparent', {
  96. SECTION: [{ // container
  97. SECTION: [{ // grand parent
  98. SECTION: [{
  99. SECTION: [{ // child
  100. TEXT_LEAF: []
  101. }]
  102. }, {
  103. SECTION: [{ // child2
  104. TEXT_LEAF: []
  105. }]
  106. }]
  107. }]
  108. }]
  109. }, {
  110. SECTION: [{ // container
  111. SECTION: [{ // child
  112. TEXT_LEAF: []
  113. }]
  114. }, {
  115. SECTION: [{ // child2
  116. TEXT_LEAF: []
  117. }]
  118. }]
  119. });
  120. yield test3(browser, t3Container);
  121. yield test4(browser, t4Container);
  122. yield testTreeOnHide(browser, accDoc, 't5_container', 't5_subcontainer', {
  123. SECTION: [{ // container
  124. SECTION: [{ // subcontainer
  125. TABLE: [{
  126. ROW: [{
  127. CELL: [{
  128. SECTION: [{ // child
  129. TEXT_LEAF: []
  130. }]
  131. }]
  132. }]
  133. }]
  134. }]
  135. }]
  136. }, {
  137. SECTION: [{ // container
  138. SECTION: [{ // child
  139. TEXT_LEAF: []
  140. }]
  141. }]
  142. });
  143. yield testTreeOnHide(browser, accDoc, 't6_container', 't6_subcontainer', {
  144. SECTION: [{ // container
  145. SECTION: [{ // subcontainer
  146. TABLE: [{
  147. ROW: [{
  148. CELL: [{
  149. TABLE: [{ // nested table
  150. ROW: [{
  151. CELL: [{
  152. SECTION: [{ // child
  153. TEXT_LEAF: []
  154. }]
  155. }]
  156. }]
  157. }]
  158. }]
  159. }]
  160. }]
  161. }, {
  162. SECTION: [{ // child2
  163. TEXT_LEAF: []
  164. }]
  165. }]
  166. }]
  167. }, {
  168. SECTION: [{ // container
  169. SECTION: [{ // child
  170. TEXT_LEAF: []
  171. }]
  172. }, {
  173. SECTION: [{ // child2
  174. TEXT_LEAF: []
  175. }]
  176. }]
  177. });
  178. });