@@ -20,7 +20,7 @@ import {
2020 dragAndDrop ,
2121 getEditorSelector ,
2222 getRect ,
23- getSpanRectFromText ,
23+ highlightSpan ,
2424 loadAndWait ,
2525 scrollIntoView ,
2626 selectEditor ,
@@ -35,14 +35,6 @@ const switchToStamp = switchToEditor.bind(null, "Stamp");
3535const switchToComment = switchToEditor . bind ( null , "Comment" ) ;
3636const switchToFreeText = switchToEditor . bind ( null , "FreeText" ) ;
3737
38- const highlightSpan = async ( page , pageIndex , text ) => {
39- const rect = await getSpanRectFromText ( page , pageIndex , text ) ;
40- const x = rect . x + rect . width / 2 ;
41- const y = rect . y + rect . height / 2 ;
42- await page . mouse . click ( x , y , { count : 2 , delay : 100 } ) ;
43- await page . waitForSelector ( getEditorSelector ( 0 ) ) ;
44- } ;
45-
4638const editComment = async ( page , editorSelector , comment ) => {
4739 const commentButtonSelector = `${ editorSelector } button.comment` ;
4840 await waitAndClick ( page , commentButtonSelector ) ;
@@ -82,16 +74,7 @@ describe("Comment", () => {
8274 await switchToHighlight ( page ) ;
8375
8476 await scrollIntoView ( page , ".textLayer span:last-of-type" ) ;
85- const rect = await getSpanRectFromText ( page , 1 , "..." ) ;
86- const x = rect . x + rect . width / 2 ;
87- const y = rect . y + rect . height / 2 ;
88- // Here and elsewhere, we add a small delay between press and release
89- // to make sure that a pointerup event is triggered after
90- // selectionchange.
91- // It works with a value of 1ms, but we use 100ms to be sure.
92- await page . mouse . click ( x , y , { count : 2 , delay : 100 } ) ;
93- await page . waitForSelector ( getEditorSelector ( 0 ) ) ;
94-
77+ await highlightSpan ( page , 1 , "..." ) ;
9578 const commentButtonSelector = `${ getEditorSelector ( 0 ) } button.comment` ;
9679 await waitAndClick ( page , commentButtonSelector ) ;
9780
@@ -137,12 +120,7 @@ describe("Comment", () => {
137120 await switchToHighlight ( page ) ;
138121
139122 await scrollIntoView ( page , ".textLayer span:nth-of-type(4)" ) ;
140- const rect = await getSpanRectFromText ( page , 1 , "World" ) ;
141- const x = rect . x + rect . width / 2 ;
142- const y = rect . y + rect . height / 2 ;
143- await page . mouse . click ( x , y , { count : 2 , delay : 100 } ) ;
144- await page . waitForSelector ( getEditorSelector ( 0 ) ) ;
145-
123+ await highlightSpan ( page , 1 , "World" ) ;
146124 const commentButtonSelector = `${ getEditorSelector ( 0 ) } button.comment` ;
147125 await waitAndClick ( page , commentButtonSelector ) ;
148126
@@ -272,7 +250,7 @@ describe("Comment", () => {
272250 pages = await loadAndWait (
273251 "tracemonkey.pdf" ,
274252 ".annotationEditorLayer" ,
275- "page-width " ,
253+ "page-fit " ,
276254 null ,
277255 { enableComment : true }
278256 ) ;
@@ -286,12 +264,7 @@ describe("Comment", () => {
286264 await Promise . all (
287265 pages . map ( async ( [ browserName , page ] ) => {
288266 await switchToHighlight ( page ) ;
289-
290- const rect = await getSpanRectFromText ( page , 1 , "Languages" ) ;
291- const x = rect . x + rect . width / 2 ;
292- const y = rect . y + rect . height / 2 ;
293- await page . mouse . click ( x , y , { count : 2 , delay : 100 } ) ;
294- await page . waitForSelector ( getEditorSelector ( 0 ) ) ;
267+ await highlightSpan ( page , 1 , "Languages" ) ;
295268
296269 let commentButtonSelector = `${ getEditorSelector ( 0 ) } button.comment` ;
297270 await page . waitForSelector ( commentButtonSelector , { visible : true } ) ;
@@ -329,12 +302,7 @@ describe("Comment", () => {
329302 await Promise . all (
330303 pages . map ( async ( [ browserName , page ] ) => {
331304 await switchToHighlight ( page ) ;
332-
333- const rect = await getSpanRectFromText ( page , 1 , "Abstract" ) ;
334- const x = rect . x + rect . width / 2 ;
335- const y = rect . y + rect . height / 2 ;
336- await page . mouse . click ( x , y , { count : 2 , delay : 100 } ) ;
337- await page . waitForSelector ( getEditorSelector ( 0 ) ) ;
305+ await highlightSpan ( page , 1 , "Abstract" ) ;
338306
339307 const comment = "Hello world!" ;
340308 await editComment ( page , getEditorSelector ( 0 ) , comment ) ;
@@ -426,12 +394,7 @@ describe("Comment", () => {
426394 await Promise . all (
427395 pages . map ( async ( [ browserName , page ] ) => {
428396 await switchToHighlight ( page ) ;
429-
430- const rect = await getSpanRectFromText ( page , 1 , "Languages" ) ;
431- const x = rect . x + rect . width / 2 ;
432- const y = rect . y + rect . height / 2 ;
433- await page . mouse . click ( x , y , { count : 2 , delay : 100 } ) ;
434- await page . waitForSelector ( getEditorSelector ( 0 ) ) ;
397+ await highlightSpan ( page , 1 , "Languages" ) ;
435398
436399 const commentButtonSelector = `${ getEditorSelector ( 0 ) } button.comment` ;
437400 await waitAndClick ( page , commentButtonSelector ) ;
@@ -539,7 +502,7 @@ describe("Comment", () => {
539502 pages = await loadAndWait (
540503 "comments.pdf" ,
541504 ".annotationEditorLayer" ,
542- "page-width " ,
505+ "page-fit " ,
543506 null ,
544507 { enableComment : true }
545508 ) ;
@@ -607,7 +570,6 @@ describe("Comment", () => {
607570 await switchToHighlight ( page ) ;
608571 await highlightSpan ( page , 1 , "Languages" ) ;
609572 const editorSelector = getEditorSelector ( 9 ) ;
610- await page . waitForSelector ( editorSelector ) ;
611573 const commentButtonSelector = `${ editorSelector } button.comment` ;
612574 await waitAndClick ( page , commentButtonSelector ) ;
613575
@@ -662,7 +624,7 @@ describe("Comment", () => {
662624 pages = await loadAndWait (
663625 "tracemonkey.pdf" ,
664626 ".annotationEditorLayer" ,
665- "page-width " ,
627+ "page-fit " ,
666628 null ,
667629 { enableComment : true }
668630 ) ;
0 commit comments