Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 65 additions & 8 deletions test/e2e/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ async function main() {

/* Prepare page */

const errorMessagesCache = [];

const page = ( await browser.pages() )[ 0 ];
await preparePage( page, injection, build );
await preparePage( page, injection, build, errorMessagesCache );

/* Loop for each file */

Expand Down Expand Up @@ -184,13 +186,64 @@ async function main() {

}

async function preparePage( page, injection, build ) {
async function preparePage( page, injection, build, errorMessages ) {

/* let page.pageSize */
/* let page.file, page.pageSize, page.error */

await page.evaluateOnNewDocument( injection );
await page.setRequestInterception( true );

page.on( 'console', async msg => {

const type = msg.type();

if ( type !== 'warning' && type !== 'error' ) {

return;

}

const file = page.file;

if ( file === undefined ) {

return;

}

let text = ( await Promise.all( msg.args().map( arg => arg.executionContext().evaluate( arg => arg instanceof Error ? arg.message : arg, arg ) ) ) ).join( ' ' ); // https://github.com/puppeteer/puppeteer/issues/3397#issuecomment-434970058

text = text.trim();
if ( text === '' ) return;

text = file + ': ' + text.replace( /\[\.WebGL-(.+?)\] /g, '' );

if ( errorMessages.includes( text ) ) {

return;

}

if ( text.includes( 'Unable to access the camera/webcam' ) ) {

return;

}

errorMessages.push( text );

if ( type === 'warning' ) {

console.yellow( text );

} else {

page.error = text;

}

} );

page.on( 'response', async ( response ) => {

try {
Expand Down Expand Up @@ -231,7 +284,9 @@ async function makeAttempt( page, failedScreenshots, cleanPage, isMakeScreenshot

try {

page.file = file;
page.pageSize = 0;
page.error = undefined;

/* Load target page */

Expand Down Expand Up @@ -295,20 +350,22 @@ async function makeAttempt( page, failedScreenshots, cleanPage, isMakeScreenshot

} catch ( e ) {

if ( e.message.includes( 'Render timeout exceeded' ) ) { // This can mean that the example doesn't use requestAnimationFrame loop
if ( ! e.message.includes( 'Render timeout exceeded' ) ) {

console.yellow( `Render timeout exceeded in file ${ file }` );
throw new Error( `Error happened while rendering file ${ file }: ${ e }` );

} else {
} /* else { // This can mean that the example doesn't use requestAnimationFrame loop

throw new Error( `Error happened while rendering file ${ file }: ${ e }` );
console.yellow( `Render timeout exceeded in file ${ file }` );

}
} */

}

const screenshot = ( await jimp.read( await page.screenshot() ) ).scale( 1 / viewScale ).quality( jpgQuality );

if ( page.error !== undefined ) throw new Error( page.error );

if ( isMakeScreenshot ) {

/* Make screenshots */
Expand Down