browser_test_select_visibility.js (2463B)
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 // test selects and options 8 addAccessibleTask( 9 `<select id="select"> 10 <option id="o1">hello</option> 11 <option id="o2">world</option> 12 </select>`, 13 async function (browser, accDoc) { 14 const select = findAccessibleChildByID(accDoc, "select"); 15 ok( 16 isAccessible(select.firstChild, [nsIAccessibleSelectable]), 17 "No selectable accessible for combobox" 18 ); 19 await untilCacheOk( 20 () => testVisibility(select, false, false), 21 "select should be on screen and visible" 22 ); 23 24 if (!browser.isRemoteBrowser) { 25 await untilCacheOk( 26 () => testVisibility(select.firstChild, false, true), 27 "combobox list should be on screen and invisible" 28 ); 29 } else { 30 // XXX: When the cache is used, states::INVISIBLE is 31 // incorrect. Test OFFSCREEN anyway. 32 await untilCacheOk(() => { 33 const [states] = getStates(select.firstChild); 34 return (states & STATE_OFFSCREEN) == 0; 35 }, "combobox list should be on screen"); 36 } 37 38 const o1 = findAccessibleChildByID(accDoc, "o1"); 39 const o2 = findAccessibleChildByID(accDoc, "o2"); 40 41 await untilCacheOk( 42 () => testVisibility(o1, false, false), 43 "option one should be on screen and visible" 44 ); 45 await untilCacheOk( 46 () => testVisibility(o2, true, false), 47 "option two should be off screen and visible" 48 ); 49 50 // Select the second option (drop-down collapsed). 51 const p = waitForEvents({ 52 expected: [ 53 [EVENT_SELECTION, "o2"], 54 [EVENT_TEXT_VALUE_CHANGE, "select"], 55 ], 56 unexpected: [ 57 stateChangeEventArgs("o2", EXT_STATE_ACTIVE, true, true), 58 stateChangeEventArgs("o1", EXT_STATE_ACTIVE, false, true), 59 ], 60 }); 61 await invokeContentTask(browser, [], () => { 62 content.document.getElementById("select").selectedIndex = 1; 63 }); 64 await p; 65 66 await untilCacheOk(() => { 67 const [states] = getStates(o1); 68 return (states & STATE_OFFSCREEN) != 0; 69 }, "option 1 should be off screen"); 70 await untilCacheOk(() => { 71 const [states] = getStates(o2); 72 return (states & STATE_OFFSCREEN) == 0; 73 }, "option 2 should be on screen"); 74 }, 75 { chrome: true, iframe: true, remoteIframe: true } 76 );