browser_alert.js (1457B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Test that alert events aren't fired when reflow happens but no actual 8 * insertion occurs. 9 */ 10 addAccessibleTask( 11 ` 12 <div id="alert" role="alert"> 13 <div id="content" hidden>content</div> 14 </div> 15 `, 16 async function (browser, docAcc) { 17 const alert = findAccessibleChildByID(docAcc, "alert"); 18 info("Showing content"); 19 await contentSpawnMutation( 20 browser, 21 { expected: [[EVENT_ALERT, alert]] }, 22 () => { 23 content.document.getElementById("content").hidden = false; 24 } 25 ); 26 info("Changing content display style and removing text"); 27 const content = findAccessibleChildByID(docAcc, "content"); 28 await contentSpawnMutation( 29 browser, 30 { 31 expected: [[EVENT_REORDER, content]], 32 unexpected: [[EVENT_ALERT, alert]], 33 }, 34 () => { 35 const node = content.document.getElementById("content"); 36 node.textContent = ""; 37 // This causes the node's layout frame to be reconstructed. This in 38 // turn causes a11y to queue it as an insertion in case there were 39 // changes. Because it already has an Accessible, This node is skipped 40 // when processing insertions, so we should not fire an alert event. 41 node.style.display = "flex"; 42 } 43 ); 44 }, 45 { chrome: true, topLevel: true, remoteIframe: true } 46 );