browser_treeupdate_gencontent.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. addAccessibleTask(`
  8. <style>
  9. .gentext:before {
  10. content: "START"
  11. }
  12. .gentext:after {
  13. content: "END"
  14. }
  15. </style>
  16. <div id="container1"></div>
  17. <div id="container2"><div id="container2_child">text</div></div>`,
  18. function*(browser, accDoc) {
  19. const id1 = 'container1';
  20. const id2 = 'container2';
  21. let container1 = findAccessibleChildByID(accDoc, id1);
  22. let container2 = findAccessibleChildByID(accDoc, id2);
  23. let tree = {
  24. SECTION: [ ] // container
  25. };
  26. testAccessibleTree(container1, tree);
  27. tree = {
  28. SECTION: [ { // container2
  29. SECTION: [ { // container2 child
  30. TEXT_LEAF: [ ] // primary text
  31. } ]
  32. } ]
  33. };
  34. testAccessibleTree(container2, tree);
  35. let onReorder = waitForEvent(EVENT_REORDER, id1);
  36. // Create and add an element with CSS generated content to container1
  37. yield ContentTask.spawn(browser, id1, id => {
  38. let node = content.document.createElement('div');
  39. node.textContent = 'text';
  40. node.setAttribute('class', 'gentext');
  41. content.document.getElementById(id).appendChild(node);
  42. });
  43. yield onReorder;
  44. tree = {
  45. SECTION: [ // container
  46. { SECTION: [ // inserted node
  47. { STATICTEXT: [] }, // :before
  48. { TEXT_LEAF: [] }, // primary text
  49. { STATICTEXT: [] } // :after
  50. ] }
  51. ]
  52. };
  53. testAccessibleTree(container1, tree);
  54. onReorder = waitForEvent(EVENT_REORDER, id2);
  55. // Add CSS generated content to an element in container2's subtree
  56. yield invokeSetAttribute(browser, 'container2_child', 'class', 'gentext');
  57. yield onReorder;
  58. tree = {
  59. SECTION: [ // container2
  60. { SECTION: [ // container2 child
  61. { STATICTEXT: [] }, // :before
  62. { TEXT_LEAF: [] }, // primary text
  63. { STATICTEXT: [] } // :after
  64. ] }
  65. ]
  66. };
  67. testAccessibleTree(container2, tree);
  68. });