/accessible/tests/mochitest/treeupdate/test_visibility.html

https://github.com/gkrilov/mozilla-central · HTML · 439 lines · 379 code · 54 blank · 6 comment · 0 complexity · 28d67e8d40333b424323d9169faefb4e MD5 · raw file

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Style visibility tree update test</title>
  5. <link rel="stylesheet" type="text/css"
  6. href="chrome://mochikit/content/tests/SimpleTest/test.css" />
  7. <script type="application/javascript"
  8. src="chrome://mochikit/content/MochiKit/packed.js"></script>
  9. <script type="application/javascript"
  10. src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  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. <script type="application/javascript">
  18. ////////////////////////////////////////////////////////////////////////////
  19. // Invokers
  20. /**
  21. * Hide parent while child stays visible.
  22. */
  23. function test1(aContainerID, aParentID, aChildID)
  24. {
  25. this.eventSeq = [
  26. new invokerChecker(EVENT_HIDE, getNode(aParentID)),
  27. new invokerChecker(EVENT_SHOW, getNode(aChildID)),
  28. new invokerChecker(EVENT_REORDER, getNode(aContainerID))
  29. ];
  30. this.invoke = function invoke()
  31. {
  32. var tree =
  33. { SECTION: [
  34. { SECTION: [
  35. { SECTION: [
  36. { TEXT_LEAF: [] }
  37. ] }
  38. ] }
  39. ] };
  40. testAccessibleTree(aContainerID, tree);
  41. getNode(aParentID).style.visibility = "hidden";
  42. }
  43. this.finalCheck = function finalCheck()
  44. {
  45. var tree =
  46. { SECTION: [
  47. { SECTION: [
  48. { TEXT_LEAF: [] }
  49. ] }
  50. ] };
  51. testAccessibleTree(aContainerID, tree);
  52. }
  53. this.getID = function getID()
  54. {
  55. return "hide parent while child stays visible";
  56. }
  57. }
  58. /**
  59. * Hide grand parent while its children stay visible.
  60. */
  61. function test2(aContainerID, aGrandParentID, aChildID, aChild2ID)
  62. {
  63. this.eventSeq = [
  64. new invokerChecker(EVENT_HIDE, getNode(aGrandParentID)),
  65. new invokerChecker(EVENT_SHOW, getNode(aChildID)),
  66. new invokerChecker(EVENT_SHOW, getNode(aChild2ID)),
  67. new invokerChecker(EVENT_REORDER, getNode(aContainerID))
  68. ];
  69. this.invoke = function invoke()
  70. {
  71. var tree =
  72. { SECTION: [ // container
  73. { SECTION: [ // grand parent
  74. { SECTION: [
  75. { SECTION: [ // child
  76. { TEXT_LEAF: [] }
  77. ] },
  78. { SECTION: [ // child2
  79. { TEXT_LEAF: [] }
  80. ] }
  81. ] }
  82. ] }
  83. ] };
  84. testAccessibleTree(aContainerID, tree);
  85. getNode(aGrandParentID).style.visibility = "hidden";
  86. }
  87. this.finalCheck = function finalCheck()
  88. {
  89. var tree =
  90. { SECTION: [ // container
  91. { SECTION: [ // child
  92. { TEXT_LEAF: [] }
  93. ] },
  94. { SECTION: [ // child2
  95. { TEXT_LEAF: [] }
  96. ] }
  97. ] };
  98. testAccessibleTree(aContainerID, tree);
  99. }
  100. this.getID = function getID()
  101. {
  102. return "hide grand parent while its children stay visible";
  103. }
  104. }
  105. /**
  106. * Change container style, hide parents while their children stay visible.
  107. */
  108. function test3(aContainerID, aParentID, aParent2ID, aChildID, aChild2ID)
  109. {
  110. this.eventSeq = [
  111. new invokerChecker(EVENT_HIDE, getNode(aParentID)),
  112. new invokerChecker(EVENT_HIDE, getNode(aParent2ID)),
  113. new invokerChecker(EVENT_SHOW, getNode(aChildID)),
  114. new invokerChecker(EVENT_SHOW, getNode(aChild2ID)),
  115. new invokerChecker(EVENT_REORDER, getNode(aContainerID))
  116. ];
  117. this.invoke = function invoke()
  118. {
  119. var tree =
  120. { SECTION: [ // container
  121. { SECTION: [ // parent
  122. { SECTION: [ // child
  123. { TEXT_LEAF: [] }
  124. ] }
  125. ] },
  126. { SECTION: [ // parent2
  127. { SECTION: [ // child2
  128. { TEXT_LEAF: [] }
  129. ] },
  130. ] }
  131. ] };
  132. testAccessibleTree(aContainerID, tree);
  133. getNode(aContainerID).style.color = "red";
  134. getNode(aParentID).style.visibility = "hidden";
  135. getNode(aParent2ID).style.visibility = "hidden";
  136. }
  137. this.finalCheck = function finalCheck()
  138. {
  139. var tree =
  140. { SECTION: [ // container
  141. { SECTION: [ // child
  142. { TEXT_LEAF: [] }
  143. ] },
  144. { SECTION: [ // child2
  145. { TEXT_LEAF: [] }
  146. ] }
  147. ] };
  148. testAccessibleTree(aContainerID, tree);
  149. }
  150. this.getID = function getID()
  151. {
  152. return "change container style, hide parents while their children stay visible";
  153. }
  154. }
  155. /**
  156. * Change container style and make visible child inside the table.
  157. */
  158. function test4(aContainerID, aChildID)
  159. {
  160. this.eventSeq = [
  161. new invokerChecker(EVENT_SHOW, getNode(aChildID)),
  162. new invokerChecker(EVENT_REORDER, getNode(aChildID).parentNode)
  163. ];
  164. this.invoke = function invoke()
  165. {
  166. var tree =
  167. { SECTION: [
  168. { TABLE: [
  169. { ROW: [
  170. { CELL: [ ] }
  171. ] }
  172. ] }
  173. ] };
  174. testAccessibleTree(aContainerID, tree);
  175. getNode(aContainerID).style.color = "red";
  176. getNode(aChildID).style.visibility = "visible";
  177. }
  178. this.finalCheck = function finalCheck()
  179. {
  180. var tree =
  181. { SECTION: [
  182. { TABLE: [
  183. { ROW: [
  184. { CELL: [
  185. { SECTION: [
  186. { TEXT_LEAF: [] }
  187. ] }
  188. ] }
  189. ] }
  190. ] }
  191. ] };
  192. testAccessibleTree(aContainerID, tree);
  193. }
  194. this.getID = function getID()
  195. {
  196. return "change container style, make visible child insdie the table";
  197. }
  198. }
  199. /**
  200. * Hide subcontainer while child inside the table stays visible.
  201. */
  202. function test5(aContainerID, aSubContainerID, aChildID)
  203. {
  204. this.eventSeq = [
  205. new invokerChecker(EVENT_HIDE, getNode(aSubContainerID)),
  206. new invokerChecker(EVENT_SHOW, getNode(aChildID)),
  207. new invokerChecker(EVENT_REORDER, getNode(aContainerID))
  208. ];
  209. this.invoke = function invoke()
  210. {
  211. var tree =
  212. { SECTION: [ // container
  213. { SECTION: [ // subcontainer
  214. { TABLE: [
  215. { ROW: [
  216. { CELL: [
  217. { SECTION: [ // child
  218. { TEXT_LEAF: [] }
  219. ] }
  220. ] }
  221. ] }
  222. ] }
  223. ] }
  224. ] };
  225. testAccessibleTree(aContainerID, tree);
  226. getNode(aSubContainerID).style.visibility = "hidden";
  227. }
  228. this.finalCheck = function finalCheck()
  229. {
  230. var tree =
  231. { SECTION: [ // container
  232. { SECTION: [ // child
  233. { TEXT_LEAF: [] }
  234. ] }
  235. ] };
  236. testAccessibleTree(aContainerID, tree);
  237. }
  238. this.getID = function getID()
  239. {
  240. return "hide subcontainer while child inside the table stays visible";
  241. }
  242. }
  243. /**
  244. * Hide subcontainer while its child and child inside the nested table stays visible.
  245. */
  246. function test6(aContainerID, aSubContainerID, aChildID, aChild2ID)
  247. {
  248. this.eventSeq = [
  249. new invokerChecker(EVENT_HIDE, getNode(aSubContainerID)),
  250. new invokerChecker(EVENT_SHOW, getNode(aChildID)),
  251. new invokerChecker(EVENT_SHOW, getNode(aChild2ID)),
  252. new invokerChecker(EVENT_REORDER, getNode(aContainerID))
  253. ];
  254. this.invoke = function invoke()
  255. {
  256. var tree =
  257. { SECTION: [ // container
  258. { SECTION: [ // subcontainer
  259. { TABLE: [
  260. { ROW: [
  261. { CELL: [
  262. { TABLE: [ // nested table
  263. { ROW: [
  264. { CELL: [
  265. { SECTION: [ // child
  266. { TEXT_LEAF: [] } ]} ]} ]} ]} ]} ]} ]},
  267. { SECTION: [ // child2
  268. { TEXT_LEAF: [] } ]} ]} ]};
  269. testAccessibleTree(aContainerID, tree);
  270. // invoke
  271. getNode(aSubContainerID).style.visibility = "hidden";
  272. }
  273. this.finalCheck = function finalCheck()
  274. {
  275. var tree =
  276. { SECTION: [ // container
  277. { SECTION: [ // child
  278. { TEXT_LEAF: [] } ]},
  279. { SECTION: [ // child2
  280. { TEXT_LEAF: [] } ]} ]};
  281. testAccessibleTree(aContainerID, tree);
  282. }
  283. this.getID = function getID()
  284. {
  285. return "hide subcontainer while its child and child inside the nested table stays visible";
  286. }
  287. }
  288. ////////////////////////////////////////////////////////////////////////////
  289. // Test
  290. //gA11yEventDumpID = "eventdump"; // debug stuff
  291. //gA11yEventDumpToConsole = true;
  292. var gQueue = null;
  293. function doTest()
  294. {
  295. gQueue = new eventQueue();
  296. gQueue.push(new test1("t1_container", "t1_parent", "t1_child"));
  297. gQueue.push(new test2("t2_container", "t2_grandparent", "t2_child", "t2_child2"));
  298. gQueue.push(new test3("t3_container", "t3_parent", "t3_parent2", "t3_child", "t3_child2"));
  299. gQueue.push(new test4("t4_container", "t4_child"));
  300. gQueue.push(new test5("t5_container", "t5_subcontainer", "t5_child"));
  301. gQueue.push(new test6("t6_container", "t6_subcontainer", "t6_child", "t6_child2"));
  302. gQueue.invoke(); // SimpleTest.finish() will be called in the end
  303. }
  304. SimpleTest.waitForExplicitFinish();
  305. addA11yLoadEvent(doTest);
  306. </script>
  307. </head>
  308. <body>
  309. <a target="_blank"
  310. title="Develop a way to handle visibility style"
  311. href="https://bugzilla.mozilla.org/show_bug.cgi?id=606125">
  312. Mozilla Bug 606125
  313. </a>
  314. <p id="display"></p>
  315. <div id="content" style="display: none"></div>
  316. <pre id="test">
  317. </pre>
  318. <!-- hide parent while child stays visible -->
  319. <div id="t1_container">
  320. <div id="t1_parent">
  321. <div id="t1_child" style="visibility: visible">text</div>
  322. </div>
  323. </div>
  324. <!-- hide grandparent while its children stay visible -->
  325. <div id="t2_container">
  326. <div id="t2_grandparent">
  327. <div>
  328. <div id="t2_child" style="visibility: visible">text</div>
  329. <div id="t2_child2" style="visibility: visible">text</div>
  330. </div>
  331. </div>
  332. </div>
  333. <!-- change container style, hide parents while their children stay visible -->
  334. <div id="t3_container">
  335. <div id="t3_parent">
  336. <div id="t3_child" style="visibility: visible">text</div>
  337. </div>
  338. <div id="t3_parent2">
  339. <div id="t3_child2" style="visibility: visible">text</div>
  340. </div>
  341. </div>
  342. <!-- change container style, show child inside the table -->
  343. <div id="t4_container">
  344. <table>
  345. <tr>
  346. <td>
  347. <div id="t4_child" style="visibility: hidden;">text</div>
  348. </td>
  349. </tr>
  350. </table>
  351. </div>
  352. <!-- hide subcontainer while child inside the table stays visible -->
  353. <div id="t5_container">
  354. <div id="t5_subcontainer">
  355. <table>
  356. <tr>
  357. <td>
  358. <div id="t5_child" style="visibility: visible;">text</div>
  359. </td>
  360. </tr>
  361. </table>
  362. </div>
  363. </div>
  364. <!-- hide subcontainer while its child and child inside the nested table stays visible -->
  365. <div id="t6_container">
  366. <div id="t6_subcontainer">
  367. <table>
  368. <tr>
  369. <td>
  370. <table>
  371. <tr>
  372. <td>
  373. <div id="t6_child" style="visibility: visible;">text</div>
  374. </td>
  375. </tr>
  376. </table>
  377. </td>
  378. </tr>
  379. </table>
  380. <div id="t6_child2" style="visibility: visible">text</div>
  381. </div>
  382. </div>
  383. <div id="eventdump"></div>
  384. </body>
  385. </html>