|
@@ -48,7 +48,7 @@ const exceptionList = [
|
|
|
'webgl_video_kinect', // video tag not deterministic enough
|
|
|
'webgl_worker_offscreencanvas', // in a worker, not robust
|
|
|
|
|
|
-].concat( ( process.platform === "win32" ) ? [
|
|
|
+].concat( ( process.platform === 'win32' ) ? [
|
|
|
|
|
|
'webgl_effects_ascii' // windows fonts not supported
|
|
|
|
|
@@ -141,21 +141,19 @@ const pup = puppeteer.launch( {
|
|
|
/* Loop for each file, with CI parallelism */
|
|
|
|
|
|
let pageSize, file, attemptProgress;
|
|
|
- let failedScreenshots = [];
|
|
|
+ const failedScreenshots = [];
|
|
|
const isParallel = 'CI' in process.env;
|
|
|
const beginId = isParallel ? Math.floor( parseInt( process.env.CI.slice( 0, 1 ) ) * files.length / 4 ) : 0;
|
|
|
const endId = isParallel ? Math.floor( ( parseInt( process.env.CI.slice( - 1 ) ) + 1 ) * files.length / 4 ) : files.length;
|
|
|
|
|
|
for ( let id = beginId; id < endId; ++ id ) {
|
|
|
|
|
|
-
|
|
|
/* At least 3 attempts before fail */
|
|
|
|
|
|
let attemptId = isMakeScreenshot ? 1.5 : 0;
|
|
|
|
|
|
while ( attemptId < maxAttemptId ) {
|
|
|
|
|
|
-
|
|
|
/* Load target page */
|
|
|
|
|
|
file = files[ id ];
|
|
@@ -175,10 +173,8 @@ const pup = puppeteer.launch( {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
try {
|
|
|
|
|
|
-
|
|
|
/* Render page */
|
|
|
|
|
|
await page.evaluate( cleanPage );
|
|
@@ -188,21 +184,23 @@ const pup = puppeteer.launch( {
|
|
|
|
|
|
/* Resource timeout */
|
|
|
|
|
|
- let resourcesSize = Math.min( 1, ( pageSize / 1024 / 1024 - pageSizeMinTax ) / pageSizeMaxTax );
|
|
|
+ const resourcesSize = Math.min( 1, ( pageSize / 1024 / 1024 - pageSizeMinTax ) / pageSizeMaxTax );
|
|
|
await new Promise( resolve => setTimeout( resolve, networkTax * resourcesSize * attemptProgress ) );
|
|
|
|
|
|
|
|
|
/* Resolve render promise */
|
|
|
|
|
|
window._renderStarted = true;
|
|
|
+
|
|
|
await new Promise( function ( resolve ) {
|
|
|
|
|
|
performance._now = performance._now || performance.now;
|
|
|
- let renderStart = performance._now();
|
|
|
|
|
|
- let waitingLoop = setInterval( function () {
|
|
|
+ const renderStart = performance._now();
|
|
|
+
|
|
|
+ const waitingLoop = setInterval( function () {
|
|
|
|
|
|
- let renderEcceded = ( performance._now() - renderStart > renderTimeout * attemptProgress );
|
|
|
+ const renderEcceded = ( performance._now() - renderStart > renderTimeout * attemptProgress );
|
|
|
if ( window._renderFinished || renderEcceded ) {
|
|
|
|
|
|
if ( renderEcceded ) {
|
|
@@ -246,9 +244,9 @@ const pup = puppeteer.launch( {
|
|
|
/* Make screenshots */
|
|
|
|
|
|
attemptId = maxAttemptId;
|
|
|
- let bitmap = ( await jimp.read( await page.screenshot() ) )
|
|
|
+ ( await jimp.read( await page.screenshot() ) )
|
|
|
.scale( 1 / viewScale ).quality( jpgQuality )
|
|
|
- .write( `./examples/screenshots/${ file }.jpg` ).bitmap;
|
|
|
+ .write( `./examples/screenshots/${ file }.jpg` );
|
|
|
|
|
|
console.green( `file: ${ file } generated` );
|
|
|
|
|
@@ -258,11 +256,12 @@ const pup = puppeteer.launch( {
|
|
|
|
|
|
/* Diff screenshots */
|
|
|
|
|
|
- let actual = ( await jimp.read( await page.screenshot() ) ).scale( 1 / viewScale ).quality( jpgQuality ).bitmap;
|
|
|
- let expected = ( await jimp.read( fs.readFileSync( `./examples/screenshots/${ file }.jpg` ) ) ).bitmap;
|
|
|
- let diff = actual;
|
|
|
+ const actual = ( await jimp.read( await page.screenshot() ) ).scale( 1 / viewScale ).quality( jpgQuality ).bitmap;
|
|
|
+ const expected = ( await jimp.read( fs.readFileSync( `./examples/screenshots/${ file }.jpg` ) ) ).bitmap;
|
|
|
+ const diff = actual;
|
|
|
|
|
|
let numFailedPixels;
|
|
|
+
|
|
|
try {
|
|
|
|
|
|
numFailedPixels = pixelmatch( expected.data, actual.data, diff.data, actual.width, actual.height, {
|