@@ -430,6 +430,41 @@ describe("server browser snapshot screenshot", () => {
430430 } ) . toEqual ( { size : [ 1280 , 800 ] , fullSize : [ 2560 , 1600 ] , colors : [ "blue" , "red" , "red" ] } ) ;
431431 } ) ;
432432
433+ it ( "records the destination of a finite entrance animation without waiting on infinite ones" , async ( ) => {
434+ const page = await context . newPage ( ) ;
435+ await page . setContent ( `
436+ <style>
437+ body { margin: 0; background: #2563eb; }
438+ @keyframes enter { from { opacity: 0; } to { opacity: 1; } }
439+ @keyframes pulse { from { opacity: 0.5; } to { opacity: 1; } }
440+ button { animation: pulse 2s infinite; }
441+ #paused { animation: enter 2s paused; }
442+ #overlay { display: none; position: fixed; inset: 0; background: #ef4444; }
443+ #overlay.open { display: block; animation: enter 200ms both; }
444+ </style>
445+ <button onclick="document.querySelector('#overlay').classList.add('open')">Open</button>
446+ <div id="paused"></div>
447+ <div id="overlay"></div>
448+ ` ) ;
449+ await page . getByRole ( "button" , { name : "Open" } ) . click ( ) ;
450+ const frame = await ServerBrowserPage . captureFinalRecordingFrame (
451+ await context . newCDPSession ( page ) ,
452+ 80 ,
453+ ) ;
454+ expect ( frame ) . toBeDefined ( ) ;
455+ const pixel = ( await page . evaluate ( `(async () => {
456+ const bytes = Uint8Array.from(atob(${ JSON . stringify ( frame ) } ), char => char.charCodeAt(0));
457+ const bitmap = await createImageBitmap(new Blob([bytes], { type: "image/jpeg" }));
458+ const canvas = document.createElement("canvas");
459+ canvas.width = bitmap.width;
460+ canvas.height = bitmap.height;
461+ const context = canvas.getContext("2d");
462+ context.drawImage(bitmap, 0, 0);
463+ return Array.from(context.getImageData(bitmap.width / 2, bitmap.height / 2, 1, 1).data);
464+ })()` ) ) as [ number , number , number , number ] ;
465+ expect ( colorOf ( pixel ) ) . toBe ( "red" ) ;
466+ } ) ;
467+
433468 it ( "shrinks the screenshot of an XML document, whose createElement makes no canvas" , async ( ) => {
434469 const page = await context . newPage ( ) ;
435470 await page . goto ( "data:text/xml,<a/>" ) ;
0 commit comments