browser_systemCaret.js (1574B)
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 /** 8 * Test that the accessibility engine correctly sets the Windows system caret. 9 * We already have cross-platform tests for GetCaretRect in 10 * accessible/tests/browser/bounds/browser_caret_rect.js. 11 * Thus, these tests are not extensive and are only to verify that the Windows 12 * system caret matches GetCaretRect. 13 */ 14 addAccessibleTask( 15 `<input id="input">`, 16 async function testSystemCaret(browser, docAcc) { 17 const input = findAccessibleChildByID(docAcc, "input", [nsIAccessibleText]); 18 info("Focusing input"); 19 let moved = waitForEvent(EVENT_TEXT_CARET_MOVED, input); 20 input.takeFocus(); 21 await moved; 22 const geckoX = {}; 23 const geckoY = {}; 24 const geckoW = {}; 25 const geckoH = {}; 26 input.getCaretRect(geckoX, geckoY, geckoW, geckoH); 27 // Windows proxies the OS caret via MSAA OBJID_CARET. This is the easiest 28 // way to query the OS caret. 29 const sysRect = await runPython(` 30 hwnd = getFirefoxHwnd() 31 caret = AccessibleObjectFromWindow(hwnd, OBJID_CARET) 32 return caret.accLocation(CHILDID_SELF) 33 `); 34 is(sysRect[0], geckoX.value, "sysX == geckoX"); 35 is(sysRect[1], geckoY.value, "sysY == geckoY"); 36 is(sysRect[2], geckoW.value, "sysW == geckoW"); 37 is(sysRect[3], geckoH.value, "sysH == geckoH"); 38 }, 39 { chrome: true, topLevel: true, iframe: true, remoteIframe: true } 40 );