@@ -675,6 +675,55 @@ void testMain() {
675
675
// TODO(mdebbar): https://github.com/flutter/flutter/issues/50769
676
676
skip: browserEngine == BrowserEngine .edge);
677
677
678
+ test ('focus and disconnection with delaying blur in iOS' , () async {
679
+ final MethodCall setClient = MethodCall (
680
+ 'TextInput.setClient' , < dynamic > [123 , flutterSinglelineConfig]);
681
+ sendFrameworkMessage (codec.encodeMethodCall (setClient));
682
+
683
+ const MethodCall setEditingState =
684
+ MethodCall ('TextInput.setEditingState' , < String , dynamic > {
685
+ 'text' : 'abcd' ,
686
+ 'selectionBase' : 2 ,
687
+ 'selectionExtent' : 3 ,
688
+ });
689
+ sendFrameworkMessage (codec.encodeMethodCall (setEditingState));
690
+
691
+ // Editing shouldn't have started yet.
692
+ expect (defaultTextEditingRoot.activeElement, null );
693
+
694
+ const MethodCall show = MethodCall ('TextInput.show' );
695
+ sendFrameworkMessage (codec.encodeMethodCall (show));
696
+
697
+ // The "setSizeAndTransform" message has to be here before we call
698
+ // checkInputEditingState, since on some platforms (e.g. Desktop Safari)
699
+ // we don't put the input element into the DOM until we get its correct
700
+ // dimensions from the framework.
701
+ final MethodCall setSizeAndTransform =
702
+ configureSetSizeAndTransformMethodCall (150 , 50 ,
703
+ Matrix4 .translationValues (10.0 , 20.0 , 30.0 ).storage.toList ());
704
+ sendFrameworkMessage (codec.encodeMethodCall (setSizeAndTransform));
705
+
706
+ checkInputEditingState (
707
+ textEditing! .strategy.domElement, 'abcd' , 2 , 3 );
708
+ expect (textEditing! .isEditing, isTrue);
709
+
710
+ // Delay for not to be a fast callback with blur.
711
+ await Future <void >.delayed (const Duration (milliseconds: 200 ));
712
+ // DOM element is blurred.
713
+ textEditing! .strategy.domElement! .blur ();
714
+
715
+ expect (spy.messages, hasLength (1 ));
716
+ expect (spy.messages[0 ].channel, 'flutter/textinput' );
717
+ expect (
718
+ spy.messages[0 ].methodName, 'TextInputClient.onConnectionClosed' );
719
+ await Future <void >.delayed (Duration .zero);
720
+ // DOM element loses the focus.
721
+ expect (defaultTextEditingRoot.activeElement, null );
722
+ },
723
+ // Test on ios-safari only.
724
+ skip: browserEngine != BrowserEngine .webkit ||
725
+ operatingSystem != OperatingSystem .iOs);
726
+
678
727
test ('finishAutofillContext closes connection no autofill element' ,
679
728
() async {
680
729
final MethodCall setClient = MethodCall (
0 commit comments