browser_reframe_visibility.js (3987B)
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/states.js */ 8 /* import-globals-from ../../mochitest/role.js */ 9 loadScripts({ name: "states.js", dir: MOCHITESTS_DIR }); 10 loadScripts({ name: "role.js", dir: MOCHITESTS_DIR }); 11 12 addAccessibleTask( 13 `<input id="textbox" value="hello"/>`, 14 async function (browser, iframeDocAcc, contentDocAcc) { 15 info( 16 "Check that the IFRAME and the IFRAME document are accessible initially." 17 ); 18 let iframeAcc = findAccessibleChildByID(contentDocAcc, DEFAULT_IFRAME_ID); 19 ok(!isDefunct(iframeAcc), "IFRAME should be accessible"); 20 ok(!isDefunct(iframeDocAcc), "IFRAME document should be accessible"); 21 22 info( 23 "Hide the IFRAME and check that it's gone along with the IFRAME document." 24 ); 25 let onEvents = waitForEvent(EVENT_REORDER, contentDocAcc); 26 await SpecialPowers.spawn(browser, [DEFAULT_IFRAME_ID], contentId => { 27 content.document.getElementById(contentId).style.display = "none"; 28 }); 29 await onEvents; 30 31 ok( 32 isDefunct(iframeAcc), 33 "IFRAME accessible should be defunct when hidden." 34 ); 35 if (gIsRemoteIframe) { 36 ok( 37 !isDefunct(iframeDocAcc), 38 "IFRAME document's accessible is not defunct when the IFRAME is hidden and fission is enabled." 39 ); 40 } else { 41 ok( 42 isDefunct(iframeDocAcc), 43 "IFRAME document's accessible is defunct when the IFRAME is hidden and fission is not enabled." 44 ); 45 } 46 ok( 47 !findAccessibleChildByID(contentDocAcc, DEFAULT_IFRAME_ID), 48 "No accessible for an IFRAME present." 49 ); 50 ok( 51 !findAccessibleChildByID(contentDocAcc, DEFAULT_IFRAME_DOC_BODY_ID), 52 "No accessible for the IFRAME document present." 53 ); 54 55 info( 56 "Show the IFRAME and check that a new accessible is created for it as " + 57 "well as the IFRAME document." 58 ); 59 60 const events = [[EVENT_REORDER, contentDocAcc]]; 61 if (!gIsRemoteIframe) { 62 events.push([ 63 EVENT_STATE_CHANGE, 64 event => { 65 const scEvent = event.QueryInterface(nsIAccessibleStateChangeEvent); 66 const id = getAccessibleDOMNodeID(event.accessible); 67 return ( 68 id === DEFAULT_IFRAME_DOC_BODY_ID && 69 scEvent.state === STATE_BUSY && 70 scEvent.isEnabled === false 71 ); 72 }, 73 ]); 74 } 75 onEvents = waitForEvents(events); 76 await SpecialPowers.spawn(browser, [DEFAULT_IFRAME_ID], contentId => { 77 content.document.getElementById(contentId).style.display = "block"; 78 }); 79 await onEvents; 80 81 iframeAcc = findAccessibleChildByID(contentDocAcc, DEFAULT_IFRAME_ID); 82 const newiframeDocAcc = iframeAcc.firstChild; 83 84 ok(!isDefunct(iframeAcc), "IFRAME should be accessible"); 85 is(iframeAcc.childCount, 1, "IFRAME accessible should have a single child"); 86 ok(newiframeDocAcc, "IFRAME document exists"); 87 ok(!isDefunct(newiframeDocAcc), "IFRAME document should be accessible"); 88 if (gIsRemoteIframe) { 89 ok( 90 !isDefunct(iframeDocAcc), 91 "Original IFRAME document accessible should not be defunct when fission is enabled." 92 ); 93 is( 94 iframeAcc.firstChild, 95 iframeDocAcc, 96 "Existing accessible is used for a IFRAME document." 97 ); 98 } else { 99 ok( 100 isDefunct(iframeDocAcc), 101 "Original IFRAME document accessible should be defunct when fission is not enabled." 102 ); 103 isnot( 104 iframeAcc.firstChild, 105 iframeDocAcc, 106 "A new accessible is created for a IFRAME document." 107 ); 108 } 109 is( 110 iframeAcc.firstChild, 111 newiframeDocAcc, 112 "A new accessible for a IFRAME document is the child of the IFRAME accessible" 113 ); 114 }, 115 { topLevel: false, iframe: true, remoteIframe: true } 116 );