@@ -5800,6 +5800,41 @@ small scripts as well as for`);
58005800 } ) ;
58015801
58025802 describe ( "Named destinations" , function ( ) {
5803+ it ( "keeps colliding deduplicated destination names unique" , async function ( ) {
5804+ let loadingTask = getDocument (
5805+ buildGetDocumentParams ( "named_dest_collision_for_editor.pdf" )
5806+ ) ;
5807+ let pdfDoc = await loadingTask . promise ;
5808+
5809+ let destinations = await pdfDoc . getDestinations ( ) ;
5810+ expect ( Object . keys ( destinations ) . sort ( ) ) . toEqual ( [ "foo" , "foo_p2" ] ) ;
5811+
5812+ const data = await pdfDoc . extractPages ( [
5813+ { document : null } ,
5814+ { document : null } ,
5815+ ] ) ;
5816+ await loadingTask . destroy ( ) ;
5817+
5818+ loadingTask = getDocument ( data ) ;
5819+ pdfDoc = await loadingTask . promise ;
5820+
5821+ destinations = await pdfDoc . getDestinations ( ) ;
5822+ expect ( Object . keys ( destinations ) . sort ( ) ) . toEqual ( [
5823+ "foo" ,
5824+ "foo_p2" ,
5825+ "foo_p2_1" ,
5826+ "foo_p2_p2" ,
5827+ ] ) ;
5828+
5829+ const secondPage = await pdfDoc . getPage ( 2 ) ;
5830+ const annots = await secondPage . getAnnotations ( ) ;
5831+ expect ( annots . length ) . toEqual ( 2 ) ;
5832+ expect ( annots [ 0 ] . dest ) . toEqual ( "foo_p2_1" ) ;
5833+ expect ( annots [ 1 ] . dest ) . toEqual ( "foo_p2_p2" ) ;
5834+
5835+ await loadingTask . destroy ( ) ;
5836+ } ) ;
5837+
58035838 it ( "extract page and check destinations" , async function ( ) {
58045839 let loadingTask = getDocument ( buildGetDocumentParams ( "issue6204.pdf" ) ) ;
58055840 let pdfDoc = await loadingTask . promise ;
0 commit comments