@@ -27,7 +27,6 @@ import {
2727 waitFor ,
2828 waitForAria ,
2929 waitForFunction ,
30- waitForFunctionWithTries ,
3130 waitForNone ,
3231 waitForVisible ,
3332} from '../../shared/helper.js' ;
@@ -253,13 +252,14 @@ export async function addBreakpointForLine(
253252 await devToolsPage . waitForFunction ( async ( ) => await isBreakpointSet ( index , devToolsPage ) ) ;
254253}
255254
256- export async function removeBreakpointForLine ( index : number | string ) {
257- const breakpointLine = await getLineNumberElement ( index ) ;
255+ export async function removeBreakpointForLine (
256+ index : number | string , devToolsPage = getBrowserAndPagesWrappers ( ) . devToolsPage ) {
257+ const breakpointLine = await getLineNumberElement ( index , devToolsPage ) ;
258258 assertNotNullOrUndefined ( breakpointLine ) ;
259259
260- await waitForFunction ( async ( ) => await isBreakpointSet ( index ) ) ;
261- await clickElement ( breakpointLine ) ;
262- await waitForFunction ( async ( ) => ! ( await isBreakpointSet ( index ) ) ) ;
260+ await devToolsPage . waitForFunction ( async ( ) => await isBreakpointSet ( index , devToolsPage ) ) ;
261+ await devToolsPage . clickElement ( breakpointLine ) ;
262+ await devToolsPage . waitForFunction ( async ( ) => ! ( await isBreakpointSet ( index , devToolsPage ) ) ) ;
263263}
264264
265265export async function addLogpointForLine ( index : number , condition : string ) {
@@ -335,9 +335,9 @@ export async function checkBreakpointDidNotActivate() {
335335}
336336
337337export async function getBreakpointDecorators (
338- disabledOnly = false , devToolsPage : DevToolsPage = getBrowserAndPagesWrappers ( ) . devToolsPage ) {
338+ disabledOnly = false , expected = 0 , devToolsPage : DevToolsPage = getBrowserAndPagesWrappers ( ) . devToolsPage ) {
339339 const selector = `.cm-breakpoint${ disabledOnly ? '-disabled' : '' } ` ;
340- const breakpointDecorators = await devToolsPage . $$ ( selector ) ;
340+ const breakpointDecorators = await devToolsPage . waitForMany ( selector , expected ) ;
341341 return await Promise . all (
342342 breakpointDecorators . map ( breakpointDecorator => breakpointDecorator . evaluate ( n => Number ( n . textContent ) ) ) ) ;
343343}
@@ -385,7 +385,8 @@ export async function switchToCallFrame(index: number) {
385385}
386386
387387export async function retrieveTopCallFrameScriptLocation (
388- script : string , target : puppeteer . Page , devToolsPage : DevToolsPage = getBrowserAndPagesWrappers ( ) . devToolsPage ) {
388+ script : string , target : puppeteer . Page | InspectedPage ,
389+ devToolsPage : DevToolsPage = getBrowserAndPagesWrappers ( ) . devToolsPage ) {
389390 // The script will run into a breakpoint, which means that it will not actually
390391 // finish the evaluation, until we continue executing.
391392 // Thus, we have to await it at a later point, while stepping through the code.
@@ -418,12 +419,12 @@ export async function retrieveTopCallFrameWithoutResuming(
418419 return scriptLocation ;
419420}
420421
421- export async function waitForStackTopMatch ( matcher : RegExp ) {
422+ export async function waitForStackTopMatch ( matcher : RegExp , devToolsPage = getBrowserAndPagesWrappers ( ) . devToolsPage ) {
422423 // The call stack is updated asynchronously, so let us wait until we see the correct one
423424 // (or report the last one we have seen before timeout).
424425 let stepLocation = '<no call stack>' ;
425- await waitForFunctionWithTries ( async ( ) => {
426- stepLocation = await retrieveTopCallFrameWithoutResuming ( ) ?? '<invalid>' ;
426+ await devToolsPage . waitForFunctionWithTries ( async ( ) => {
427+ stepLocation = await retrieveTopCallFrameWithoutResuming ( devToolsPage ) ?? '<invalid>' ;
427428 return stepLocation ?. match ( matcher ) ;
428429 } , { tries : 10 } ) ;
429430 return stepLocation ;
0 commit comments