@@ -76,5 +76,41 @@ public async Task EntryAlignmentMatchesFlowDirection(bool isExplicit, FlowDirect
7676
7777 Assert . Equal ( expectedAlignment , nativeAlignment ) ;
7878 }
79+
80+ [ Fact ]
81+ [ Description ( "Password entry should refresh obfuscation when identical text is pasted" ) ]
82+ public async Task PasswordEntryObfuscatesIdenticalPastedText ( )
83+ {
84+ var entry = new Entry
85+ {
86+ Text = "password123" ,
87+ IsPassword = true
88+ } ;
89+
90+ await InvokeOnMainThreadAsync ( ( ) =>
91+ {
92+ var handler = CreateHandler < EntryHandler > ( entry ) ;
93+ var platformControl = GetPlatformControl ( handler ) ;
94+ var passwordTextBox = platformControl as Microsoft . Maui . Platform . MauiPasswordTextBox ;
95+
96+ Assert . NotNull ( passwordTextBox ) ;
97+ Assert . True ( passwordTextBox . IsPassword ) ;
98+
99+ // Verify the text is initially obfuscated
100+ Assert . Equal ( new string ( '●' , entry . Text . Length ) , passwordTextBox . Text ) ;
101+
102+ // Simulate pasting the same text by setting the same text value
103+ passwordTextBox . Text = "password123" ;
104+
105+ // This is equivalent to what happens when a user pastes identical text via Ctrl+V
106+ passwordTextBox . GetType ( ) . GetMethod ( "UpdatePasswordIfNeeded" ,
107+ System . Reflection . BindingFlags . NonPublic |
108+ System . Reflection . BindingFlags . Instance ) ? . Invoke ( passwordTextBox , null ) ;
109+
110+
111+ // Verify the text is still properly obfuscated after the "paste" operation
112+ Assert . Equal ( new string ( '●' , entry . Text . Length ) , passwordTextBox . Text ) ;
113+ } ) ;
114+ }
79115 }
80116}
0 commit comments