@@ -3309,4 +3309,52 @@ describe("FreeText Editor", () => {
33093309 ) ;
33103310 } ) ;
33113311 } ) ;
3312+
3313+ describe ( "Freetext and text alignment" , ( ) => {
3314+ let pages ;
3315+
3316+ beforeEach ( async ( ) => {
3317+ pages = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" ) ;
3318+ } ) ;
3319+
3320+ afterEach ( async ( ) => {
3321+ await closePages ( pages ) ;
3322+ } ) ;
3323+
3324+ it ( "must check that the alignment is correct" , async ( ) => {
3325+ await Promise . all (
3326+ pages . map ( async ( [ browserName , page ] ) => {
3327+ await switchToFreeText ( page ) ;
3328+
3329+ const rect = await getRect ( page , ".annotationEditorLayer" ) ;
3330+ const editorSelector = getEditorSelector ( 0 ) ;
3331+
3332+ const data = "Hello PDF.js World !!" ;
3333+ await page . mouse . click ( rect . x + 100 , rect . y + 100 ) ;
3334+ await page . waitForSelector ( editorSelector , { visible : true } ) ;
3335+ await page . type ( `${ editorSelector } .internal` , data ) ;
3336+ await commit ( page ) ;
3337+ await waitForSerialized ( page , 1 ) ;
3338+
3339+ let alignment = await page . $eval (
3340+ `${ editorSelector } .internal` ,
3341+ el => getComputedStyle ( el ) . textAlign
3342+ ) ;
3343+ expect ( alignment ) . withContext ( `In ${ browserName } ` ) . toEqual ( "start" ) ;
3344+
3345+ await page . click ( "#secondaryToolbarToggleButton" ) ;
3346+ await page . waitForSelector ( "#secondaryToolbar" , { visible : true } ) ;
3347+ await page . click ( "#spreadOdd" ) ;
3348+ await page . waitForSelector ( "#secondaryToolbar" , { visible : false } ) ;
3349+ await page . waitForSelector ( ".spread" ) ;
3350+
3351+ alignment = await page . $eval (
3352+ `${ editorSelector } .internal` ,
3353+ el => getComputedStyle ( el ) . textAlign
3354+ ) ;
3355+ expect ( alignment ) . withContext ( `In ${ browserName } ` ) . toEqual ( "start" ) ;
3356+ } )
3357+ ) ;
3358+ } ) ;
3359+ } ) ;
33123360} ) ;
0 commit comments