@@ -1776,7 +1776,7 @@ void _testIncrementables() {
17761776
17771777 pumpSemantics (isFocused: true );
17781778 expect (capturedActions, < CapturedAction > [
1779- (0 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
1779+ (0 , ui.SemanticsAction .focus , null ),
17801780 ]);
17811781 capturedActions.clear ();
17821782
@@ -1787,10 +1787,12 @@ void _testIncrementables() {
17871787 isEmpty,
17881788 );
17891789
1790+ // The web doesn't send didLoseAccessibilityFocus as on the web,
1791+ // accessibility focus is not observable, only input focus is. As of this
1792+ // writing, there is no SemanticsAction.unfocus action, so the test simply
1793+ // asserts that no actions are being sent as a result of blur.
17901794 element.blur ();
1791- expect (capturedActions, < CapturedAction > [
1792- (0 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
1793- ]);
1795+ expect (capturedActions, isEmpty);
17941796
17951797 semantics ().semanticsEnabled = false ;
17961798 });
@@ -1821,15 +1823,14 @@ void _testTextField() {
18211823
18221824
18231825 final SemanticsObject node = owner ().debugSemanticsTree! [0 ]! ;
1826+ final TextField textFieldRole = node.primaryRole! as TextField ;
1827+ final DomHTMLInputElement inputElement = textFieldRole.activeEditableElement as DomHTMLInputElement ;
18241828
18251829 // TODO(yjbanov): this used to attempt to test that value="hello" but the
18261830 // test was a false positive. We should revise this test and
18271831 // make sure it tests the right things:
18281832 // https://github.com/flutter/flutter/issues/147200
1829- expect (
1830- (node.element as DomHTMLInputElement ).value,
1831- isNull,
1832- );
1833+ expect (inputElement.value, '' );
18331834
18341835 expect (node.primaryRole? .role, PrimaryRole .textField);
18351836 expect (
@@ -1852,8 +1853,8 @@ void _testTextField() {
18521853 final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder ();
18531854 updateNode (
18541855 builder,
1855- actions: 0 | ui.SemanticsAction .didGainAccessibilityFocus .index,
1856- flags: 0 | ui.SemanticsFlag .isTextField.index,
1856+ actions: 0 | ui.SemanticsAction .focus .index,
1857+ flags: 0 | ui.SemanticsFlag .isTextField.index | ui. SemanticsFlag .isEnabled.index ,
18571858 value: 'hello' ,
18581859 transform: Matrix4 .identity ().toFloat64 (),
18591860 rect: const ui.Rect .fromLTRB (0 , 0 , 100 , 50 ),
@@ -1870,7 +1871,7 @@ void _testTextField() {
18701871
18711872 expect (owner ().semanticsHost.ownerDocument? .activeElement, textField);
18721873 expect (await logger.idLog.first, 0 );
1873- expect (await logger.actionLog.first, ui.SemanticsAction .didGainAccessibilityFocus );
1874+ expect (await logger.actionLog.first, ui.SemanticsAction .focus );
18741875
18751876 semantics ().semanticsEnabled = false ;
18761877 }, // TODO(yjbanov): https://github.com/flutter/flutter/issues/46638
@@ -2156,7 +2157,7 @@ void _testCheckables() {
21562157
21572158 pumpSemantics (isFocused: true );
21582159 expect (capturedActions, < CapturedAction > [
2159- (0 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
2160+ (0 , ui.SemanticsAction .focus , null ),
21602161 ]);
21612162 capturedActions.clear ();
21622163
@@ -2166,15 +2167,12 @@ void _testCheckables() {
21662167 pumpSemantics (isFocused: false );
21672168 expect (capturedActions, isEmpty);
21682169
2169- // If the element is blurred by the browser, then we do want to notify the
2170- // framework. This is because screen reader can be focused on something
2171- // other than what the framework is focused on, and notifying the framework
2172- // about the loss of focus on a node is information that the framework did
2173- // not have before.
2170+ // The web doesn't send didLoseAccessibilityFocus as on the web,
2171+ // accessibility focus is not observable, only input focus is. As of this
2172+ // writing, there is no SemanticsAction.unfocus action, so the test simply
2173+ // asserts that no actions are being sent as a result of blur.
21742174 element.blur ();
2175- expect (capturedActions, < CapturedAction > [
2176- (0 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
2177- ]);
2175+ expect (capturedActions, isEmpty);
21782176
21792177 semantics ().semanticsEnabled = false ;
21802178 });
@@ -2340,17 +2338,19 @@ void _testTappable() {
23402338
23412339 pumpSemantics (isFocused: true );
23422340 expect (capturedActions, < CapturedAction > [
2343- (0 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
2341+ (0 , ui.SemanticsAction .focus , null ),
23442342 ]);
23452343 capturedActions.clear ();
23462344
23472345 pumpSemantics (isFocused: false );
23482346 expect (capturedActions, isEmpty);
23492347
2348+ // The web doesn't send didLoseAccessibilityFocus as on the web,
2349+ // accessibility focus is not observable, only input focus is. As of this
2350+ // writing, there is no SemanticsAction.unfocus action, so the test simply
2351+ // asserts that no actions are being sent as a result of blur.
23502352 element.blur ();
2351- expect (capturedActions, < CapturedAction > [
2352- (0 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
2353- ]);
2353+ expect (capturedActions, isEmpty);
23542354
23552355 semantics ().semanticsEnabled = false ;
23562356 });
@@ -3180,7 +3180,7 @@ void _testDialog() {
31803180 expect (
31813181 capturedActions,
31823182 < CapturedAction > [
3183- (2 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
3183+ (2 , ui.SemanticsAction .focus , null ),
31843184 ],
31853185 );
31863186
@@ -3242,7 +3242,7 @@ void _testDialog() {
32423242 expect (
32433243 capturedActions,
32443244 < CapturedAction > [
3245- (3 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
3245+ (3 , ui.SemanticsAction .focus , null ),
32463246 ],
32473247 );
32483248
@@ -3392,7 +3392,7 @@ void _testFocusable() {
33923392 pumpSemantics (); // triggers post-update callbacks
33933393 expect (domDocument.activeElement, element);
33943394 expect (capturedActions, < CapturedAction > [
3395- (1 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
3395+ (1 , ui.SemanticsAction .focus , null ),
33963396 ]);
33973397 capturedActions.clear ();
33983398
@@ -3405,17 +3405,19 @@ void _testFocusable() {
34053405 // Browser blurs the element
34063406 element.blur ();
34073407 expect (domDocument.activeElement, isNot (element));
3408- expect (capturedActions, < CapturedAction > [
3409- (1 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
3410- ]);
3408+ // The web doesn't send didLoseAccessibilityFocus as on the web,
3409+ // accessibility focus is not observable, only input focus is. As of this
3410+ // writing, there is no SemanticsAction.unfocus action, so the test simply
3411+ // asserts that no actions are being sent as a result of blur.
3412+ expect (capturedActions, isEmpty);
34113413 capturedActions.clear ();
34123414
34133415 // Request focus again
34143416 manager.changeFocus (true );
34153417 pumpSemantics (); // triggers post-update callbacks
34163418 expect (domDocument.activeElement, element);
34173419 expect (capturedActions, < CapturedAction > [
3418- (1 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
3420+ (1 , ui.SemanticsAction .focus , null ),
34193421 ]);
34203422 capturedActions.clear ();
34213423
0 commit comments