browser_custom_actions.js (1162B)
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/role.js */ 8 /* import-globals-from ../../mochitest/states.js */ 9 loadScripts( 10 { name: "role.js", dir: MOCHITESTS_DIR }, 11 { name: "states.js", dir: MOCHITESTS_DIR } 12 ); 13 14 // Test custom action 15 addAccessibleTask( 16 `<div id="container"> 17 <dialog aria-actions="btn" id="dlg" open> 18 Hello 19 <form method="dialog"> 20 <button id="btn">Close</button> 21 </form> 22 </dialog> 23 </div>`, 24 async (browser, accDoc) => { 25 let dialog = getNativeInterface(accDoc, "dlg"); 26 let actionNames = dialog.actionNames; 27 let customAction = actionNames.find(name => name.startsWith("Name:Close")); 28 ok(!!customAction, "Dialog should have a custom action"); 29 is( 30 dialog.getActionDescription(customAction), 31 "Close", 32 "Correct action description" 33 ); 34 35 const reorder = waitForEvent(EVENT_REORDER, "container"); 36 dialog.performAction(customAction); 37 await reorder; 38 } 39 );