browser_osPicker.js (1661B)
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 addAccessibleTask( 8 `<input id="file" type="file">`, 9 async function (browser, docAcc) { 10 info("Focusing file input"); 11 await runPython(` 12 global focused 13 focused = WaitForWinEvent(EVENT_OBJECT_FOCUS, "file") 14 `); 15 const file = findAccessibleChildByID(docAcc, "file"); 16 file.takeFocus(); 17 await runPython(` 18 focused.wait() 19 `); 20 ok(true, "file input got focus"); 21 info("Opening file picker"); 22 await runPython(` 23 global focused 24 focused = WaitForWinEvent( 25 EVENT_OBJECT_FOCUS, 26 lambda evt: getWindowClass(evt.hwnd) == "Edit" 27 ) 28 `); 29 file.doAction(0); 30 await runPython(` 31 global event 32 event = focused.wait() 33 `); 34 ok(true, "Picker got focus"); 35 info("Dismissing picker"); 36 await runPython(` 37 # If the picker is dismissed too quickly, it seems to re-enable the root 38 # window before we do. This sleep isn't ideal, but it's more likely to 39 # reproduce the case that our root window gets focus before it is enabled. 40 # See bug 1883568 for further details. 41 import time 42 time.sleep(1) 43 focused = WaitForWinEvent(EVENT_OBJECT_FOCUS, "file") 44 # Sending key presses to the picker is unreliable, so use WM_CLOSE. 45 pickerRoot = user32.GetAncestor(event.hwnd, GA_ROOT) 46 user32.SendMessageW(pickerRoot, WM_CLOSE, 0, 0) 47 focused.wait() 48 `); 49 ok(true, "file input got focus"); 50 } 51 );