@@ -94,15 +94,13 @@ void testMain() {
9494
9595 expectSemanticsTree (owner (), '<sem><input type="text" /></sem>' );
9696
97- // TODO(yjbanov): this used to attempt to test that value="hello" but the
98- // test was a false positive. We should revise this test and
99- // make sure it tests the right things:
100- // https://github.com/flutter/flutter/issues/147200
97+ // `outerHTML` does not include the `value` property, so it is checked
98+ // on the element directly.
10199 final SemanticsObject node = owner ().debugSemanticsTree! [0 ]! ;
102100 final textFieldRole = node.semanticRole! as SemanticTextField ;
103101 final inputElement = textFieldRole.editableElement as DomHTMLInputElement ;
104102 expect (inputElement.tagName.toLowerCase (), 'input' );
105- expect (inputElement.value, '' );
103+ expect (inputElement.value, 'hello ' );
106104 expect (inputElement.disabled, isFalse);
107105 expect (inputElement.getAttribute ('aria-required' ), isNull);
108106 });
@@ -156,6 +154,44 @@ void testMain() {
156154 final inputElement = textFieldRole.editableElement as DomHTMLInputElement ;
157155 expect (inputElement.tagName.toLowerCase (), 'input' );
158156 expect (inputElement.disabled, isTrue);
157+ // A disabled field is never focused, so its value has to come from
158+ // semantics for screen readers to read it.
159+ expect (inputElement.value, 'hello' );
160+ });
161+
162+ test ('updates the value of a field that is not being edited' , () {
163+ final SemanticsObject node = createTextFieldSemantics (value: 'hello' );
164+ final inputElement =
165+ (node.semanticRole! as SemanticTextField ).editableElement as DomHTMLInputElement ;
166+ expect (inputElement.value, 'hello' );
167+
168+ createTextFieldSemantics (value: 'bye' );
169+ expect (inputElement.value, 'bye' );
170+ });
171+
172+ test ('renders the value of a multi-line field that is not being edited' , () {
173+ final SemanticsObject node = createTextFieldSemantics (value: 'hello' , isMultiline: true );
174+ final textArea =
175+ (node.semanticRole! as SemanticTextField ).editableElement as DomHTMLTextAreaElement ;
176+ expect (textArea.value, 'hello' );
177+ });
178+
179+ test ('does not write the masked value of an obscured field' , () {
180+ final SemanticsObject node = createTextFieldSemantics (value: '•••' , isObscured: true );
181+ final inputElement =
182+ (node.semanticRole! as SemanticTextField ).editableElement as DomHTMLInputElement ;
183+ expect (inputElement.value, '' );
184+ });
185+
186+ test ('does not write the value of a field owned by an autofill group' , () {
187+ final SemanticsObject node = createTextFieldSemantics (value: 'hello' );
188+ final inputElement =
189+ (node.semanticRole! as SemanticTextField ).editableElement as DomHTMLInputElement ;
190+ inputElement.name = 'username' ;
191+ inputElement.value = 'autofilled' ;
192+
193+ createTextFieldSemantics (value: 'bye' );
194+ expect (inputElement.value, 'autofilled' );
159195 });
160196
161197 test ('sends a SemanticsAction.focus action when browser requests focus' , () async {
0 commit comments