@@ -408,8 +408,8 @@ extension RunnerTests {
408408 // be stale after the field repositions on focus (e.g. the Settings search bar jumps
409409 // bottom->top and reveals a "Suggestions" list) — tapping there navigates away instead of
410410 // clearing; and replacing into an already-empty field is a no-op anyway.
411- // textValueForClear returns nil for secure (and unknown) fields, and on iOS for a placeholder
412- // that is itself a mask, where we CANNOT confirm emptiness — those must still be cleared, or
411+ // textValueForClear returns nil for secure (and unknown) fields, and for a placeholder that is
412+ // itself a mask, where we CANNOT confirm emptiness — those must still be cleared, or
413413 // replace would concatenate stale + new text. So distinguish nil (clear) from "" (skip). On iOS
414414 // the masked route below can still prove a masked field empty.
415415 let existing = textValueForClear ( input . attributes )
@@ -424,24 +424,25 @@ extension RunnerTests {
424424 // a secure field on its first delete after the field takes focus, and deletes from a caret left
425425 // at the end reach the rest, so deletes go first and the caret moves only for masked text left.
426426 if textValueRead ( for : input . attributes ) == . unreadable {
427- if maskedTextShown ( by : input ) == . empty {
428- return
429- }
430- // Deletes into a field without focus record an XCTest failure, which tears down the runner. The
431- // focus step can leave focus unconfirmed, so the field gets the readiness repeat at its center,
432- // clear of a control at the edge.
427+ // Deletes or text sent to a field without focus record an XCTest failure, which tears down the
428+ // runner. The focus step can leave focus unconfirmed, so the field gets the readiness repeat at
429+ // its center, clear of a control at the edge, even when it is empty and needs no clear.
433430 if input . snapshot . map ( { snapshotHasKeyboardFocus ( $0 ) } ) != true {
434431 try reader . dispatch { try retapAt ( read : input , app : app , element : input . element ) }
435432 }
433+ if maskedTextShown ( by : input ) == . empty {
434+ return
435+ }
436436 let burst = Self . textClearBurst ( valueLength : valueLength )
437437 reader . dispatch { input . element . typeText ( String ( repeating : XCUIKeyboardKey . delete . rawValue , count : burst ) ) }
438- // An input that stops answering (#3060) goes on to the caret tap and burst below.
439- if let cleared = try reader . input ( ) {
440- let shown = maskedTextShown ( by : cleared )
441- NSLog ( " AGENT_DEVICE_RUNNER_TEXT_ENTRY_CLEAR route=masked-deletes shown=%@ " , String ( describing : shown ) )
442- if shown == . empty || shown == . maskPlaceholder {
443- return
444- }
438+ // An input that stops answering (#3060) has had its one burst, as below.
439+ guard let cleared = try reader . input ( ) else {
440+ return
441+ }
442+ let shown = maskedTextShown ( by : cleared )
443+ NSLog ( " AGENT_DEVICE_RUNNER_TEXT_ENTRY_CLEAR route=masked-deletes shown=%@ " , String ( describing : shown ) )
444+ if shown != . text {
445+ return
445446 }
446447 }
447448#endif
@@ -547,11 +548,8 @@ extension RunnerTests {
547548 case empty
548549 /// A placeholder that is itself a mask, which text of the same length shows too.
549550 case maskPlaceholder
550- /// A mask other than the placeholder, so text is in the field.
551- case mask
552- /// Any other value, which says nothing about the text. Like `.mask`, it leaves the clear to the
553- /// caret tap; the clear's log line tells the two apart.
554- case unknown
551+ /// Anything else, such as a mask other than the placeholder: text may be in the field.
552+ case text
555553 }
556554
557555 static func maskedTextShown ( value : String , showsPlaceholder : Bool ) -> MaskedTextShown {
@@ -562,7 +560,7 @@ extension RunnerTests {
562560 if showsPlaceholder {
563561 return isMaskedTextValue ( shown ) ? . maskPlaceholder : . empty
564562 }
565- return isMaskedTextValue ( shown ) ? . mask : . unknown
563+ return . text
566564 }
567565
568566 /// `maskedTextShown(value:showsPlaceholder:)` for `input`, with the placeholder rule the shared read uses.
@@ -808,17 +806,16 @@ extension RunnerTests {
808806 }
809807
810808 /// The text a clear can trust in the input `attributes` describe, with a placeholder read as empty;
811- /// nil when unreadable. On iOS a placeholder that is itself a mask is nil too, since text of its length
812- /// shows it as well: the masked clear reads that field back instead of skipping it.
809+ /// nil when unreadable. A placeholder that is itself a mask is nil too, since text of its length shows
810+ /// it as well, so that field is cleared instead of skipped. Only the clear reads it this way: the
811+ /// shared read keeps such a placeholder empty for verification, as a PIN field that shows its digits needs.
813812 func textValueForClear ( _ attributes : ( any XCUIElementAttributes ) ? ) -> String ? {
814813 guard let value = editableTextValue ( for : attributes , treatingPlaceholderAsEmpty : true ) else {
815814 return nil
816815 }
817- #if os( iOS )
818816 if value . isEmpty , Self . isMaskedTextValue ( normalizedElementText ( attributes ? . value ) ) {
819817 return nil
820818 }
821- #endif
822819 return value
823820 }
824821
0 commit comments