@@ -121,6 +121,52 @@ describe('script', () => {
121121 } ) ;
122122 } ) ;
123123
124+ it ( 'work for scripts that trigger dialogs and dismiss them' , async ( ) => {
125+ await withMcpContext ( async ( response , context ) => {
126+ const page = context . getSelectedPptrPage ( ) ;
127+
128+ await page . setContent ( html `< button id ="test "> test</ button > ` ) ;
129+
130+ await evaluateScript ( ) . handler (
131+ {
132+ params : {
133+ function : String ( ( ) => {
134+ return confirm ( 'hello' ) ;
135+ } ) ,
136+ dialogAction : 'dismiss' ,
137+ } ,
138+ } ,
139+ response ,
140+ context ,
141+ ) ;
142+ const lineEvaluation = response . responseLines . at ( 2 ) ! ;
143+ assert . strictEqual ( JSON . parse ( lineEvaluation ) , false ) ;
144+ } ) ;
145+ } ) ;
146+
147+ it ( 'work for scripts that trigger prompts and fill them' , async ( ) => {
148+ await withMcpContext ( async ( response , context ) => {
149+ const page = context . getSelectedPptrPage ( ) ;
150+
151+ await page . setContent ( html `< button id ="test "> test</ button > ` ) ;
152+
153+ await evaluateScript ( ) . handler (
154+ {
155+ params : {
156+ function : String ( ( ) => {
157+ return prompt ( 'Enter your name:' ) ;
158+ } ) ,
159+ dialogAction : 'John Doe' ,
160+ } ,
161+ } ,
162+ response ,
163+ context ,
164+ ) ;
165+ const lineEvaluation = response . responseLines . at ( 2 ) ! ;
166+ assert . strictEqual ( JSON . parse ( lineEvaluation ) , 'John Doe' ) ;
167+ } ) ;
168+ } ) ;
169+
124170 it ( 'work for async functions' , async ( ) => {
125171 await withMcpContext ( async ( response , context ) => {
126172 const page = context . getSelectedPptrPage ( ) ;
0 commit comments