Skip to content

Commit

Permalink
Prevent unrelated canvas locator timing out
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderBart committed Oct 18, 2023
1 parent 9905301 commit e84537e
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions test/performance/fixtures/perf-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,19 @@ export class PerfUtils {
* @return Locator for the editor canvas element.
*/
async getCanvas() {
return await Promise.any( [
( async () => {
const legacyCanvasLocator = this.page.locator(
'.wp-block-post-content'
);
await legacyCanvasLocator.waitFor( {
timeout: 120_000,
} );
return legacyCanvasLocator;
} )(),
( async () => {
const iframedCanvasLocator = this.page.frameLocator(
'[name=editor-canvas]'
);
await iframedCanvasLocator
.locator( 'body' )
.waitFor( { timeout: 120_000 } );
return iframedCanvasLocator;
} )(),
] );
const canvasLocator = this.page.locator(
'.wp-block-post-content, iframe[name=editor-canvas]'
);

const isFramed = await canvasLocator.evaluate(
( node ) => node.tagName === 'IFRAME'
);

if ( isFramed ) {
return canvasLocator.frameLocator( ':scope' );
}

return canvasLocator;
}

/**
Expand Down

0 comments on commit e84537e

Please sign in to comment.