browser_aria_placeholder.js (2269B)
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 inputs with placeholder text expose it via AXPlaceholderValue and 9 * correctly _avoid_ exposing it via AXTItle, AXValue, or AXDescription. Verify AXPlaceholderValue is not exposed when the placeholder is used as the name. 10 */ 11 addAccessibleTask( 12 ` 13 <input id="input" placeholder="Name"><br> 14 <label for="input2">Enter Name</label><input id="input2" placeholder="Name" value="Elmer Fudd"> 15 `, 16 (browser, accDoc) => { 17 let input = getNativeInterface(accDoc, "input"); 18 let input2 = getNativeInterface(accDoc, "input2"); 19 20 is( 21 input.getAttributeValue("AXPlaceholderValue"), 22 null, 23 "Placeholder is used as name, so no AXPlaceholderValue is stored." 24 ); 25 is(input.getAttributeValue("AXDescription"), "Name"); 26 is(input.getAttributeValue("AXTitle"), "", "Correct title"); 27 is(input.getAttributeValue("AXValue"), "", "Correct value"); 28 29 is( 30 input2.getAttributeValue("AXPlaceholderValue"), 31 "Name", 32 "Correct placeholder value in presence of value" 33 ); 34 is(input2.getAttributeValue("AXTitle"), "Enter Name", "Correct label"); 35 is(input2.getAttributeValue("AXDescription"), null, "Correct title"); 36 is(input2.getAttributeValue("AXValue"), "Elmer Fudd", "Correct value"); 37 } 38 ); 39 40 /** 41 * Test that aria-placeholder gets exposed via AXPlaceholderValue and correctly 42 * contributes to AXValue (but not title or description). 43 */ 44 addAccessibleTask( 45 ` 46 <span id="date-of-birth">Birthday</span> 47 <div 48 id="bday" 49 contenteditable 50 role="textbox" 51 aria-labelledby="date-of-birth" 52 aria-placeholder="MM-DD-YYYY">MM-DD-YYYY</div> 53 `, 54 (browser, accDoc) => { 55 let bday = getNativeInterface(accDoc, "bday"); 56 57 is( 58 bday.getAttributeValue("AXPlaceholderValue"), 59 "MM-DD-YYYY", 60 "Correct placeholder value" 61 ); 62 is(bday.getAttributeValue("AXDescription"), null, "Correct label"); 63 is(bday.getAttributeValue("AXTitle"), "Birthday", "Correct title"); 64 is(bday.getAttributeValue("AXValue"), "MM-DD-YYYY", "Correct value"); 65 } 66 );