@@ -37,6 +37,7 @@ import {
3737 kbModifierDown ,
3838 kbModifierUp ,
3939 kbRedo ,
40+ kbSelectAll ,
4041 kbUndo ,
4142 loadAndWait ,
4243 moveEditor ,
@@ -3547,4 +3548,62 @@ describe("FreeText Editor", () => {
35473548 ) ;
35483549 } ) ;
35493550 } ) ;
3551+
3552+ describe ( "Delete some annotations, scroll to the end and then scroll to the beginning" , ( ) => {
3553+ let pages ;
3554+
3555+ beforeEach ( async ( ) => {
3556+ pages = await loadAndWait (
3557+ "tracemonkey_with_annotations.pdf" ,
3558+ ".annotationEditorLayer"
3559+ ) ;
3560+ } ) ;
3561+
3562+ afterEach ( async ( ) => {
3563+ await closePages ( pages ) ;
3564+ } ) ;
3565+
3566+ it ( "must check that the annotations aren't displayed after scrolling" , async ( ) => {
3567+ await Promise . all (
3568+ pages . map ( async ( [ browserName , page ] ) => {
3569+ await switchToFreeText ( page ) ;
3570+
3571+ await kbSelectAll ( page ) ;
3572+ await page . waitForFunction (
3573+ ( ) => document . querySelectorAll ( ".selectedEditor" ) . length === 4
3574+ ) ;
3575+
3576+ await page . keyboard . press ( "Backspace" ) ;
3577+ await page . waitForFunction ( ( ) => {
3578+ const { map } =
3579+ window . PDFViewerApplication . pdfDocument . annotationStorage
3580+ . serializable ;
3581+ return (
3582+ map . size === 4 && [ ...map . values ( ) ] . every ( entry => entry . deleted )
3583+ ) ;
3584+ } ) ;
3585+
3586+ // Disable editing mode.
3587+ await switchToFreeText ( page , /* disable = */ true ) ;
3588+
3589+ const oneToOne = Array . from ( new Array ( 13 ) . keys ( ) , n => n + 2 ) . concat (
3590+ Array . from ( new Array ( 13 ) . keys ( ) , n => 13 - n )
3591+ ) ;
3592+ for ( const pageNumber of oneToOne ) {
3593+ await scrollIntoView (
3594+ page ,
3595+ `.page[data-page-number = "${ pageNumber } "]`
3596+ ) ;
3597+ }
3598+
3599+ await page . waitForFunction (
3600+ ( ) =>
3601+ document . querySelectorAll (
3602+ `.annotationLayer > section:is(.stampAnnotation, .inkAnnotation, .highlightAnnotation, .freeTextAnnotation)[hidden = ""]`
3603+ ) . length === 4
3604+ ) ;
3605+ } )
3606+ ) ;
3607+ } ) ;
3608+ } ) ;
35503609} ) ;
0 commit comments