browser_test_focus_browserui.js (1868B)
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( 10 { name: "states.js", dir: MOCHITESTS_DIR }, 11 { name: "role.js", dir: MOCHITESTS_DIR } 12 ); 13 14 async function runTests(browser) { 15 await SpecialPowers.pushPrefEnv({ 16 // If Fission is disabled, the pref is no-op. 17 set: [["fission.bfcacheInParent", true]], 18 }); 19 20 let onFocus = waitForEvent(EVENT_FOCUS, "input"); 21 EventUtils.synthesizeKey("VK_TAB", {}, browser.ownerGlobal); 22 let evt = await onFocus; 23 testStates(evt.accessible, STATE_FOCUSED); 24 25 onFocus = waitForEvent(EVENT_FOCUS, "buttonInputDoc"); 26 let url = snippetToURL(`<input id="input" type="button" value="button">`, { 27 contentDocBodyAttrs: { id: "buttonInputDoc" }, 28 }); 29 browser.loadURI(Services.io.newURI(url), { 30 triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), 31 }); 32 evt = await onFocus; 33 testStates(evt.accessible, STATE_FOCUSED); 34 35 onFocus = waitForEvent(EVENT_FOCUS, "input"); 36 browser.goBack(); 37 evt = await onFocus; 38 testStates(evt.accessible, STATE_FOCUSED); 39 40 onFocus = waitForEvent( 41 EVENT_FOCUS, 42 event => event.accessible.DOMNode == gURLBar.inputField 43 ); 44 EventUtils.synthesizeKey("t", { accelKey: true }, browser.ownerGlobal); 45 evt = await onFocus; 46 testStates(evt.accessible, STATE_FOCUSED); 47 48 onFocus = waitForEvent(EVENT_FOCUS, "input"); 49 EventUtils.synthesizeKey("w", { accelKey: true }, browser.ownerGlobal); 50 evt = await onFocus; 51 testStates(evt.accessible, STATE_FOCUSED); 52 } 53 54 /** 55 * Accessibility loading document events test. 56 */ 57 addAccessibleTask(`<input id="input">`, runTests);