@@ -1799,6 +1799,60 @@ describe("FreeText Editor", () => {
17991799 } ) ;
18001800 } ) ;
18011801
1802+ describe ( "FreeText (open existing generated with Cairo)" , ( ) => {
1803+ let pages ;
1804+
1805+ beforeEach ( async ( ) => {
1806+ pages = await loadAndWait (
1807+ "issue20504.pdf" ,
1808+ ".annotationEditorLayer" ,
1809+ 100
1810+ ) ;
1811+ } ) ;
1812+
1813+ afterEach ( async ( ) => {
1814+ await closePages ( pages ) ;
1815+ } ) ;
1816+
1817+ it ( "must open some existing annotations" , async ( ) => {
1818+ await Promise . all (
1819+ pages . map ( async ( [ browserName , page ] ) => {
1820+ const boxes = [ ] ;
1821+ for ( const num of [ 48 , 49 , 50 , 51 , 52 ] ) {
1822+ const id = `${ num } R` ;
1823+ await page . waitForSelector ( getAnnotationSelector ( id ) , {
1824+ visible : true ,
1825+ } ) ;
1826+ const rect = await getRect ( page , getAnnotationSelector ( id ) ) ;
1827+ boxes . push ( rect ) ;
1828+ }
1829+
1830+ await switchToFreeText ( page ) ;
1831+
1832+ for ( let i = 0 ; i < boxes . length ; i ++ ) {
1833+ const rect = await getRect (
1834+ page ,
1835+ `#pdfjs_internal_editor_${ i } -editor`
1836+ ) ;
1837+
1838+ expect ( Math . abs ( rect . width - boxes [ i ] . width ) <= 20 )
1839+ . withContext ( `In ${ browserName } ` )
1840+ . toEqual ( true ) ;
1841+ expect ( Math . abs ( rect . height - boxes [ i ] . height ) <= 20 )
1842+ . withContext ( `In ${ browserName } ` )
1843+ . toEqual ( true ) ;
1844+ expect ( Math . abs ( rect . x - boxes [ i ] . x ) <= 20 )
1845+ . withContext ( `In ${ browserName } ` )
1846+ . toEqual ( true ) ;
1847+ expect ( Math . abs ( rect . y - boxes [ i ] . y ) <= 20 )
1848+ . withContext ( `In ${ browserName } ` )
1849+ . toEqual ( true ) ;
1850+ }
1851+ } )
1852+ ) ;
1853+ } ) ;
1854+ } ) ;
1855+
18021856 describe ( "Keyboard shortcuts when the editor layer isn't focused" , ( ) => {
18031857 let pages ;
18041858
0 commit comments