@@ -24,7 +24,6 @@ test('fill withholds keys until the tapped point holds text-entry focus', async
24242525 ] ) ;
2626 assert . deepEqual ( world . transcript , [
27- 'keyboard' ,
2827 'active' ,
2928 'tap' ,
3029 'active' ,
@@ -39,24 +38,22 @@ test('fill withholds keys until the tapped point holds text-entry focus', async
3938// whose keyboard is already up. The keyboard says "a field is focused" both
4039// before and after, so only the focused element's own geometry can tell whether
4140// OUR tap moved focus.
42- test ( 'fill accepts a keyboard-up second field once focus lands on the tapped point' , async ( ) => {
41+ test ( 'fill accepts a second field once focus lands on the tapped point' , async ( ) => {
4342 const world = createTextEntryWorld ( ) ;
44- world . keyboardShown = [ true ] ;
4543 world . focusedBeforeTap = PREVIOUS_FIELD ;
4644 world . activeRects = [ CONTAINS_TAP ] ;
4745
4846 const result = await runFill ( world ) ;
4947
5048 assert . equal ( result ?. textEntryReadiness , 'focused-element' ) ;
51- assert . deepEqual ( world . transcript , [ 'keyboard' , ' active', 'tap' , 'active' , 'clear' , 'keys' ] ) ;
49+ assert . deepEqual ( world . transcript , [ 'active' , 'tap' , 'active' , 'clear' , 'keys' ] ) ;
5250} ) ;
5351
5452// P1, the two-field misdelivery: email filled, keyboard stays up, the password
5553// tap misses. Focus never leaves the email field, so a global `/keys` would
5654// append the password to the EMAIL field while reporting success.
57- test ( 'fill refuses when a keyboard-up tap misses and focus stays on the previous field' , async ( ) => {
55+ test ( 'fill refuses when a tap misses and focus stays on the previous field' , async ( ) => {
5856 const world = createTextEntryWorld ( ) ;
59- world . keyboardShown = [ true ] ;
6057 world . focusedBeforeTap = PREVIOUS_FIELD ;
6158 world . activeRects = [ PREVIOUS_FIELD ] ;
6259
@@ -96,60 +93,38 @@ test('fill accepts a re-fill of the already-focused field it tapped', async () =
9693 assert . equal ( result ?. textEntryReadiness , 'focused-element' ) ;
9794} ) ;
9895
99- test ( 'fill refuses replacement when only the keyboard transition can confirm focus' , async ( ) => {
100- const world = createTextEntryWorld ( ) ;
101- world . activeRoute = 'unimplemented' ;
102- world . keyboardShown = [ false , false , true ] ;
103-
104- await assert . rejects ( runFill ( world ) , ( error : AppError ) => {
105- assert . equal ( error . code , 'UNSUPPORTED_OPERATION' ) ;
106- assert . equal ( error . details ?. reason , 'text_entry_clear_target_unavailable' ) ;
107- return true ;
108- } ) ;
109- assert . deepEqual ( world . transcript , [
110- 'keyboard' ,
111- 'active' ,
112- 'tap' ,
113- 'active' ,
114- 'keyboard' ,
115- 'keyboard' ,
116- ] ) ;
117- } ) ;
96+ for ( const keyboardRoute of [ 'ok' , 'unimplemented' , 'failing' ] as const ) {
97+ test ( `fill refuses before tapping when focused-element lookup is unsupported (${ keyboardRoute } keyboard)` , async ( ) => {
98+ const world = createTextEntryWorld ( ) ;
99+ world . activeRoute = 'unimplemented' ;
100+ world . keyboardRoute = keyboardRoute ;
118101
119- // Without an active-element route, a keyboard that was ALREADY up witnesses
120- // nothing about the new field — the exact silent misdelivery P1 names.
121- test ( 'fill refuses a keyboard-up tap when the driver cannot report the focused field' , async ( ) => {
122- const world = createTextEntryWorld ( ) ;
123- world . activeRoute = 'unimplemented' ;
124- world . keyboardShown = [ true ] ;
102+ await assert . rejects ( runFill ( world ) , ( error : AppError ) => {
103+ assert . equal ( error . code , 'UNSUPPORTED_OPERATION' ) ;
104+ assert . equal ( error . details ?. reason , 'text_entry_clear_target_unavailable' ) ;
105+ return true ;
106+ } ) ;
125107
126- await assert . rejects ( runFill ( world ) , ( error : AppError ) => {
127- assert . match ( error . message , / c a n n o t r e p o r t w h i c h f i e l d h o l d s f o c u s / ) ;
128- assert . equal ( error . details ?. reason , 'text_entry_focus_not_observed' ) ;
129- return true ;
108+ assert . deepEqual ( world . transcript , [ 'active' ] ) ;
109+ assert . deepEqual ( world . probeTimeouts , [ 1_500 ] ) ;
130110 } ) ;
111+ }
131112
132- assert . ok ( ! world . transcript . some ( ( step ) => step === 'clear' || step === 'keys' ) ) ;
133- } ) ;
134-
135- // The last path that typed without evidence. It reported ordinary success, and
136- // nothing renders `textEntryReadiness`, so it read to a caller exactly like a
137- // fill that worked — the #1658 false success this change exists to remove.
138- test ( 'fill refuses when the driver implements neither focus route' , async ( ) => {
113+ test ( 'fill refuses when focused-element lookup becomes unsupported after the tap' , async ( ) => {
139114 const world = createTextEntryWorld ( ) ;
140115 world . activeRoute = 'unimplemented' ;
141- world . keyboardRoute = 'unimplemented' ;
116+ world . client . activeElementReference = async ( ) => {
117+ world . transcript . push ( 'active' ) ;
118+ return { id : 'previous' } ;
119+ } ;
142120
143121 await assert . rejects ( runFill ( world ) , ( error : AppError ) => {
144- assert . equal ( error . code , 'COMMAND_FAILED' ) ;
145- assert . match ( error . message , / r e p o r t s n e i t h e r t h e f o c u s e d e l e m e n t n o r k e y b o a r d s t a t e / ) ;
146- // A capability gap, not a missed tap: the caller's next move differs.
147- assert . equal ( error . details ?. reason , 'text_entry_focus_unobservable' ) ;
148- assert . match ( String ( error . details ?. hint ) , / p r e s s < t a r g e t > f o l l o w e d b y t y p e < t e x t > / ) ;
122+ assert . equal ( error . code , 'UNSUPPORTED_OPERATION' ) ;
123+ assert . equal ( error . details ?. reason , 'text_entry_clear_target_unavailable' ) ;
149124 return true ;
150125 } ) ;
151126
152- assert . ok ( ! world . transcript . some ( ( step ) => step === 'clear' || step === 'keys' ) ) ;
127+ assert . deepEqual ( world . transcript , [ 'active' , 'tap' , 'active' ] ) ;
153128} ) ;
154129
155130// The #1658 report is "fill answered Filled N chars while the field kept its
@@ -171,17 +146,17 @@ test('fill refuses without typing when nothing ever takes focus', async () => {
171146
172147// A probe that FAILED is not a driver without the feature. Swallowing a dead
173148// session or a grid outage as "unsupported" would degrade it into a blind type.
174- test ( 'fill propagates a failing keyboard probe instead of typing blind' , async ( ) => {
149+ test ( 'fill propagates a failing pre-tap focus probe instead of typing blind' , async ( ) => {
175150 const world = createTextEntryWorld ( ) ;
176- world . keyboardRoute = 'failing' ;
151+ world . activeRoute = 'failing' ;
177152
178153 await assert . rejects ( runFill ( world ) , ( error : AppError ) => {
179- assert . match ( error . message , / i n v a l i d s e s s i o n i d / ) ;
154+ assert . match ( error . message , / a c t i v e e l e m e n t e x p l o d e d / ) ;
180155 return true ;
181156 } ) ;
182157
183158 // It threw on a pre-tap probe, so the device was never touched at all.
184- assert . deepEqual ( world . transcript , [ 'keyboard' , ' active'] ) ;
159+ assert . deepEqual ( world . transcript , [ 'active' ] ) ;
185160} ) ;
186161
187162// Post-tap the device HAS been touched, so one transient grid error must not
@@ -198,12 +173,12 @@ test('fill tolerates a transient probe failure and still witnesses focus', async
198173
199174// ...but a budget that expires without a single answered probe is a broken
200175// session, and must surface as itself rather than as "the tap missed".
201- test ( 'fill rethrows the probe failure when no probe ever answers' , async ( ) => {
176+ test ( 'fill rethrows the probe failure when no post-tap probe ever answers' , async ( ) => {
202177 const world = createTextEntryWorld ( ) ;
203- world . activeRoute = 'failing' ;
178+ world . activeFailuresAfterTap = Number . POSITIVE_INFINITY ;
204179
205180 await assert . rejects ( runFill ( world ) , ( error : AppError ) => {
206- assert . match ( error . message , / a c t i v e e l e m e n t e x p l o d e d / ) ;
181+ assert . match ( error . message , / t r a n s i e n t g r i d b l i p / ) ;
207182 return true ;
208183 } ) ;
209184
@@ -246,7 +221,7 @@ test('fill clears an empty replacement without sending keys', async () => {
246221 } ) ;
247222
248223 await interactor . fill ( 12 , 24 , '' ) ;
249- assert . deepEqual ( world . transcript , [ 'keyboard' , ' active', 'tap' , 'active' , 'clear' ] ) ;
224+ assert . deepEqual ( world . transcript , [ 'active' , 'tap' , 'active' , 'clear' ] ) ;
250225} ) ;
251226
252227test ( 'iOS WebDriver interactor routes snapshots through the acquisition adapter' , async ( ) => {
@@ -400,8 +375,8 @@ async function runFill(world: ReturnType<typeof createTextEntryWorld>) {
400375}
401376
402377/**
403- * Records the request order `fill` produces. The ordering IS the fix: a `keys`
404- * entry that follows `tap` with no keyboard evidence between them is the bug.
378+ * Records the request order `fill` produces. Clearing or typing before the
379+ * tapped field holds confirmed focus is the bug.
405380 */
406381type FocusedElement = {
407382 id : string ;
@@ -424,7 +399,6 @@ function createTextEntryWorld() {
424399 const world = {
425400 transcript : [ ] as string [ ] ,
426401 probeTimeouts : [ ] as Array < number | undefined > ,
427- keyboardShown : [ true ] as boolean [ ] ,
428402 /** How the driver answers each route: normally, not at all, or with a real failure. */
429403 keyboardRoute : 'ok' as 'ok' | 'unimplemented' | 'failing' ,
430404 activeRoute : 'ok' as 'ok' | 'unimplemented' | 'failing' ,
@@ -484,10 +458,7 @@ function createTextEntryWorld() {
484458 // why the client classifies on the W3C error code instead.
485459 throw new AppError ( 'COMMAND_FAILED' , 'invalid session id' , { status : 404 } ) ;
486460 }
487- // The last programmed reading is what the keyboard stays at.
488- return world . keyboardShown . length > 1
489- ? world . keyboardShown . shift ( ) !
490- : world . keyboardShown [ 0 ] ! ;
461+ return true ;
491462 } ,
492463 } as unknown as WebDriverClient ;
493464 return world ;
0 commit comments