@@ -3,6 +3,7 @@ import os from "node:os";
33import path from "node:path" ;
44import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
55import {
6+ clickChromeMcpCoords ,
67 clickChromeMcpElement ,
78 buildChromeMcpArgs ,
89 decodeChromeMcpStderrTail ,
@@ -509,6 +510,31 @@ describe("chrome MCP page parsing", () => {
509510 expect ( result ) . toBe ( 123 ) ;
510511 } ) ;
511512
513+ it ( "defaults non-finite coordinate click delays before injecting the browser script" , async ( ) => {
514+ const session = createFakeSession ( ) ;
515+ const callTool = vi . fn ( async ( { name } : ToolCall ) => {
516+ if ( name === "evaluate_script" ) {
517+ return { content : [ { type : "text" , text : "```json\nnull\n```" } ] } ;
518+ }
519+ throw new Error ( `unexpected tool ${ name } ` ) ;
520+ } ) ;
521+ session . client . callTool = callTool as typeof session . client . callTool ;
522+ setChromeMcpSessionFactoryForTest ( async ( ) => session ) ;
523+
524+ await clickChromeMcpCoords ( {
525+ profileName : "chrome-live" ,
526+ targetId : "1" ,
527+ x : 10 ,
528+ y : 20 ,
529+ delayMs : Number . NaN ,
530+ } ) ;
531+
532+ const callToolMock = callTool as unknown as ToolCallMock ;
533+ const evaluateCall = callToolMock . mock . calls . find ( ( [ call ] ) => call . name === "evaluate_script" ) ;
534+ const fn = evaluateCall ?. [ 0 ] . arguments ?. function ;
535+ expect ( typeof fn === "string" ? fn : "" ) . toContain ( "const delayMs = 0;" ) ;
536+ } ) ;
537+
512538 it ( "does not cache an ephemeral availability probe before the next real attach" , async ( ) => {
513539 let factoryCalls = 0 ;
514540 const closeMocks : Array < ReturnType < typeof vi . fn > > = [ ] ;
0 commit comments