browser_treeupdate_gencontent.js (2504B)
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 5 "use strict"; 6 7 /* import-globals-from ../../mochitest/role.js */ 8 loadScripts({ name: "role.js", dir: MOCHITESTS_DIR }); 9 10 addAccessibleTask( 11 ` 12 <style> 13 .gentext:before { 14 content: "START" 15 } 16 .gentext:after { 17 content: "END" 18 } 19 </style> 20 <div id="container1"></div> 21 <div id="container2"><div id="container2_child">text</div></div>`, 22 async function (browser, accDoc) { 23 const id1 = "container1"; 24 const id2 = "container2"; 25 let container1 = findAccessibleChildByID(accDoc, id1); 26 let container2 = findAccessibleChildByID(accDoc, id2); 27 28 let tree = { 29 SECTION: [], // container 30 }; 31 testAccessibleTree(container1, tree); 32 33 tree = { 34 SECTION: [ 35 { 36 // container2 37 SECTION: [ 38 { 39 // container2 child 40 TEXT_LEAF: [], // primary text 41 }, 42 ], 43 }, 44 ], 45 }; 46 testAccessibleTree(container2, tree); 47 48 let onReorder = waitForEvent(EVENT_REORDER, id1); 49 // Create and add an element with CSS generated content to container1 50 await invokeContentTask(browser, [id1], id => { 51 let node = content.document.createElement("div"); 52 node.textContent = "text"; 53 node.setAttribute("class", "gentext"); 54 content.document.getElementById(id).appendChild(node); 55 }); 56 await onReorder; 57 58 tree = { 59 SECTION: [ 60 // container 61 { 62 SECTION: [ 63 // inserted node 64 { STATICTEXT: [] }, // :before 65 { TEXT_LEAF: [] }, // primary text 66 { STATICTEXT: [] }, // :after 67 ], 68 }, 69 ], 70 }; 71 testAccessibleTree(container1, tree); 72 73 onReorder = waitForEvent(EVENT_REORDER, "container2_child"); 74 // Add CSS generated content to an element in container2's subtree 75 await invokeSetAttribute(browser, "container2_child", "class", "gentext"); 76 await onReorder; 77 78 tree = { 79 SECTION: [ 80 // container2 81 { 82 SECTION: [ 83 // container2 child 84 { STATICTEXT: [] }, // :before 85 { TEXT_LEAF: [] }, // primary text 86 { STATICTEXT: [] }, // :after 87 ], 88 }, 89 ], 90 }; 91 testAccessibleTree(container2, tree); 92 }, 93 { iframe: true, remoteIframe: true } 94 );