Fix keyboard shortcuts on mac and for some tests make sure that all
the page is displayed in using page-fit in order to make all tested elements visible.
This commit is contained in:
		
							parent
							
								
									34781121cd
								
							
						
					
					
						commit
						517a262fb1
					
				@ -15,6 +15,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  closePages,
 | 
					  closePages,
 | 
				
			||||||
 | 
					  kbCopy,
 | 
				
			||||||
 | 
					  kbSelectAll,
 | 
				
			||||||
  loadAndWait,
 | 
					  loadAndWait,
 | 
				
			||||||
  mockClipboard,
 | 
					  mockClipboard,
 | 
				
			||||||
  waitForEvent,
 | 
					  waitForEvent,
 | 
				
			||||||
@ -23,9 +25,7 @@ import {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const selectAll = async page => {
 | 
					const selectAll = async page => {
 | 
				
			||||||
  const promise = waitForEvent(page, "selectionchange");
 | 
					  const promise = waitForEvent(page, "selectionchange");
 | 
				
			||||||
  await page.keyboard.down("Control");
 | 
					  await kbSelectAll(page);
 | 
				
			||||||
  await page.keyboard.press("a");
 | 
					 | 
				
			||||||
  await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
  await promise;
 | 
					  await promise;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await page.waitForFunction(() => {
 | 
					  await page.waitForFunction(() => {
 | 
				
			||||||
@ -64,9 +64,7 @@ describe("Copy and paste", () => {
 | 
				
			|||||||
          await selectAll(page);
 | 
					          await selectAll(page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          const promise = waitForEvent(page, "copy");
 | 
					          const promise = waitForEvent(page, "copy");
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbCopy(page);
 | 
				
			||||||
          await page.keyboard.press("c");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await promise;
 | 
					          await promise;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.waitForFunction(
 | 
					          await page.waitForFunction(
 | 
				
			||||||
@ -173,9 +171,7 @@ describe("Copy and paste", () => {
 | 
				
			|||||||
          await selectAll(page);
 | 
					          await selectAll(page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          const promise = waitForEvent(page, "copy");
 | 
					          const promise = waitForEvent(page, "copy");
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbCopy(page);
 | 
				
			||||||
          await page.keyboard.press("c");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await promise;
 | 
					          await promise;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.waitForFunction(
 | 
					          await page.waitForFunction(
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,20 @@ import {
 | 
				
			|||||||
  getFirstSerialized,
 | 
					  getFirstSerialized,
 | 
				
			||||||
  getSelectedEditors,
 | 
					  getSelectedEditors,
 | 
				
			||||||
  getSerialized,
 | 
					  getSerialized,
 | 
				
			||||||
 | 
					  hover,
 | 
				
			||||||
 | 
					  kbBigMoveDown,
 | 
				
			||||||
 | 
					  kbBigMoveLeft,
 | 
				
			||||||
 | 
					  kbBigMoveRight,
 | 
				
			||||||
 | 
					  kbBigMoveUp,
 | 
				
			||||||
 | 
					  kbCopy,
 | 
				
			||||||
 | 
					  kbGoToBegin,
 | 
				
			||||||
 | 
					  kbGoToEnd,
 | 
				
			||||||
 | 
					  kbModifierDown,
 | 
				
			||||||
 | 
					  kbModifierUp,
 | 
				
			||||||
 | 
					  kbPaste,
 | 
				
			||||||
 | 
					  kbRedo,
 | 
				
			||||||
 | 
					  kbSelectAll,
 | 
				
			||||||
 | 
					  kbUndo,
 | 
				
			||||||
  loadAndWait,
 | 
					  loadAndWait,
 | 
				
			||||||
  scrollIntoView,
 | 
					  scrollIntoView,
 | 
				
			||||||
  waitForEvent,
 | 
					  waitForEvent,
 | 
				
			||||||
@ -33,24 +47,18 @@ import { PNG } from "pngjs";
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const copyPaste = async page => {
 | 
					const copyPaste = async page => {
 | 
				
			||||||
  let promise = waitForEvent(page, "copy");
 | 
					  let promise = waitForEvent(page, "copy");
 | 
				
			||||||
  await page.keyboard.down("Control");
 | 
					  await kbCopy(page);
 | 
				
			||||||
  await page.keyboard.press("c");
 | 
					 | 
				
			||||||
  await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
  await promise;
 | 
					  await promise;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await page.waitForTimeout(10);
 | 
					  await page.waitForTimeout(10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  promise = waitForEvent(page, "paste");
 | 
					  promise = waitForEvent(page, "paste");
 | 
				
			||||||
  await page.keyboard.down("Control");
 | 
					  await kbPaste(page);
 | 
				
			||||||
  await page.keyboard.press("v");
 | 
					 | 
				
			||||||
  await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
  await promise;
 | 
					  await promise;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const selectAll = async page => {
 | 
					const selectAll = async page => {
 | 
				
			||||||
  await page.keyboard.down("Control");
 | 
					  await kbSelectAll(page);
 | 
				
			||||||
  await page.keyboard.press("a");
 | 
					 | 
				
			||||||
  await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
  await page.waitForFunction(
 | 
					  await page.waitForFunction(
 | 
				
			||||||
    () => !document.querySelector(".freeTextEditor:not(.selectedEditor)")
 | 
					    () => !document.querySelector(".freeTextEditor:not(.selectedEditor)")
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
@ -264,9 +272,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          visible: true,
 | 
					          visible: true,
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await page.keyboard.down("Control");
 | 
					        await kbUndo(page);
 | 
				
			||||||
        await page.keyboard.press("z");
 | 
					 | 
				
			||||||
        await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
        await page.waitForFunction(
 | 
					        await page.waitForFunction(
 | 
				
			||||||
          sel => !document.querySelector(sel),
 | 
					          sel => !document.querySelector(sel),
 | 
				
			||||||
          {},
 | 
					          {},
 | 
				
			||||||
@ -275,17 +281,13 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        for (let i = 0; i < 2; i++) {
 | 
					        for (let i = 0; i < 2; i++) {
 | 
				
			||||||
          const promise = waitForEvent(page, "paste");
 | 
					          const promise = waitForEvent(page, "paste");
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbPaste(page);
 | 
				
			||||||
          await page.keyboard.press("v");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await promise;
 | 
					          await promise;
 | 
				
			||||||
          await page.waitForSelector(getEditorSelector(5 + i));
 | 
					          await page.waitForSelector(getEditorSelector(5 + i));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (let i = 0; i < 2; i++) {
 | 
					        for (let i = 0; i < 2; i++) {
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbUndo(page);
 | 
				
			||||||
          await page.keyboard.press("z");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await page.waitForFunction(
 | 
					          await page.waitForFunction(
 | 
				
			||||||
            sel => !document.querySelector(sel),
 | 
					            sel => !document.querySelector(sel),
 | 
				
			||||||
            {},
 | 
					            {},
 | 
				
			||||||
@ -473,26 +475,20 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          page.$eval(`${getEditorSelector(9)} .internal`, el => el.innerText);
 | 
					          page.$eval(`${getEditorSelector(9)} .internal`, el => el.innerText);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // We're in the middle of the text.
 | 
					        // We're in the middle of the text.
 | 
				
			||||||
        await page.keyboard.down("Control");
 | 
					        await kbUndo(page);
 | 
				
			||||||
        await page.keyboard.press("z");
 | 
					 | 
				
			||||||
        await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
        await waitForTextChange(prevText);
 | 
					        await waitForTextChange(prevText);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let text = (prevText = await getText());
 | 
					        let text = (prevText = await getText());
 | 
				
			||||||
        expect(text).withContext(`In ${browserName}`).toEqual("AAAA");
 | 
					        expect(text).withContext(`In ${browserName}`).toEqual("AAAA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await page.keyboard.down("Control");
 | 
					        await kbUndo(page);
 | 
				
			||||||
        await page.keyboard.press("z");
 | 
					 | 
				
			||||||
        await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
        await waitForTextChange(prevText);
 | 
					        await waitForTextChange(prevText);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        text = prevText = await getText();
 | 
					        text = prevText = await getText();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        expect(text).withContext(`In ${browserName}`).toEqual("AAA");
 | 
					        expect(text).withContext(`In ${browserName}`).toEqual("AAA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await page.keyboard.down("Control");
 | 
					        await kbRedo(page);
 | 
				
			||||||
        await page.keyboard.press("y");
 | 
					 | 
				
			||||||
        await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
        await waitForTextChange(prevText);
 | 
					        await waitForTextChange(prevText);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        text = prevText = await getText();
 | 
					        text = prevText = await getText();
 | 
				
			||||||
@ -500,9 +496,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
        expect(text).withContext(`In ${browserName}`).toEqual("AAAA");
 | 
					        expect(text).withContext(`In ${browserName}`).toEqual("AAAA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (let i = 0; i < 4; i++) {
 | 
					        for (let i = 0; i < 4; i++) {
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbUndo(page);
 | 
				
			||||||
          await page.keyboard.press("z");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          if (i < 3) {
 | 
					          if (i < 3) {
 | 
				
			||||||
            await waitForTextChange(prevText);
 | 
					            await waitForTextChange(prevText);
 | 
				
			||||||
            prevText = await getText();
 | 
					            prevText = await getText();
 | 
				
			||||||
@ -513,9 +507,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          () => !document.querySelector(".selectedEditor")
 | 
					          () => !document.querySelector(".selectedEditor")
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await page.keyboard.down("Control");
 | 
					        await kbRedo(page);
 | 
				
			||||||
        await page.keyboard.press("y");
 | 
					 | 
				
			||||||
        await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
        await page.waitForSelector(getEditorSelector(9), {
 | 
					        await page.waitForSelector(getEditorSelector(9), {
 | 
				
			||||||
          visible: true,
 | 
					          visible: true,
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@ -570,16 +562,16 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
        const rect = await page.$eval(".annotationEditorLayer", el => {
 | 
					        const rect = await page.$eval(".annotationEditorLayer", el => {
 | 
				
			||||||
          // With Chrome something is wrong when serializing a DomRect,
 | 
					          // With Chrome something is wrong when serializing a DomRect,
 | 
				
			||||||
          // hence we extract the values and just return them.
 | 
					          // hence we extract the values and just return them.
 | 
				
			||||||
          const { x, y } = el.getBoundingClientRect();
 | 
					          const { x, y, width, height } = el.getBoundingClientRect();
 | 
				
			||||||
          return { x, y };
 | 
					          return { x, y, width, height };
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const editorCenters = [];
 | 
					        const editorCenters = [];
 | 
				
			||||||
        for (let i = 0; i < 4; i++) {
 | 
					        for (let i = 0; i < 4; i++) {
 | 
				
			||||||
          const data = `FreeText ${i}`;
 | 
					          const data = `FreeText ${i}`;
 | 
				
			||||||
          await page.mouse.click(
 | 
					          await page.mouse.click(
 | 
				
			||||||
            rect.x + (i + 1) * 100,
 | 
					            rect.x + ((i + 1) * rect.width) / 10,
 | 
				
			||||||
            rect.y + (i + 1) * 100
 | 
					            rect.y + ((i + 1) * rect.height) / 10
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
          await page.waitForSelector(getEditorSelector(i), {
 | 
					          await page.waitForSelector(getEditorSelector(i), {
 | 
				
			||||||
            visible: true,
 | 
					            visible: true,
 | 
				
			||||||
@ -617,7 +609,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          .toEqual([0, 1, 2, 3]);
 | 
					          .toEqual([0, 1, 2, 3]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Unselect the editor.
 | 
					        // Unselect the editor.
 | 
				
			||||||
        await page.keyboard.down("Control");
 | 
					        await kbModifierDown(page);
 | 
				
			||||||
        await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
 | 
					        await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
 | 
				
			||||||
        await waitForUnselectedEditor(page, getEditorSelector(1));
 | 
					        await waitForUnselectedEditor(page, getEditorSelector(1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -633,7 +625,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          .toEqual([0, 3]);
 | 
					          .toEqual([0, 3]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
 | 
					        await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
 | 
				
			||||||
        await page.keyboard.up("Control");
 | 
					        await kbModifierUp(page);
 | 
				
			||||||
        await waitForSelectedEditor(page, getEditorSelector(1));
 | 
					        await waitForSelectedEditor(page, getEditorSelector(1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        expect(await getSelectedEditors(page))
 | 
					        expect(await getSelectedEditors(page))
 | 
				
			||||||
@ -663,7 +655,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          .withContext(`In ${browserName}`)
 | 
					          .withContext(`In ${browserName}`)
 | 
				
			||||||
          .toEqual([1]);
 | 
					          .toEqual([1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await page.keyboard.down("Control");
 | 
					        await kbModifierDown(page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await page.mouse.click(editorCenters[3].x, editorCenters[3].y);
 | 
					        await page.mouse.click(editorCenters[3].x, editorCenters[3].y);
 | 
				
			||||||
        await waitForSelectedEditor(page, getEditorSelector(3));
 | 
					        await waitForSelectedEditor(page, getEditorSelector(3));
 | 
				
			||||||
@ -671,7 +663,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          .withContext(`In ${browserName}`)
 | 
					          .withContext(`In ${browserName}`)
 | 
				
			||||||
          .toEqual([1, 3]);
 | 
					          .toEqual([1, 3]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await page.keyboard.up("Control");
 | 
					        await kbModifierUp(page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Delete 1 and 3.
 | 
					        // Delete 1 and 3.
 | 
				
			||||||
        await page.keyboard.press("Backspace");
 | 
					        await page.keyboard.press("Backspace");
 | 
				
			||||||
@ -688,7 +680,10 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          .toEqual([0, 2, 4, 5, 6]);
 | 
					          .toEqual([0, 2, 4, 5, 6]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Create an empty editor.
 | 
					        // Create an empty editor.
 | 
				
			||||||
        await page.mouse.click(rect.x + 700, rect.y + 100);
 | 
					        await page.mouse.click(
 | 
				
			||||||
 | 
					          rect.x + (rect.width / 10) * 7,
 | 
				
			||||||
 | 
					          rect.y + rect.height / 10
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
        await page.waitForSelector(getEditorSelector(7), {
 | 
					        await page.waitForSelector(getEditorSelector(7), {
 | 
				
			||||||
          visible: true,
 | 
					          visible: true,
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@ -704,7 +699,10 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          .toEqual([2]);
 | 
					          .toEqual([2]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Create an empty editor.
 | 
					        // Create an empty editor.
 | 
				
			||||||
        await page.mouse.click(rect.x + 700, rect.y + 100);
 | 
					        await page.mouse.click(
 | 
				
			||||||
 | 
					          rect.x + (rect.width / 10) * 8,
 | 
				
			||||||
 | 
					          rect.y + rect.height / 10
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
        await page.waitForSelector(getEditorSelector(8), {
 | 
					        await page.waitForSelector(getEditorSelector(8), {
 | 
				
			||||||
          visible: true,
 | 
					          visible: true,
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@ -1057,9 +1055,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
            `${getEditorSelector(0)} .overlay:not(.enabled)`
 | 
					            `${getEditorSelector(0)} .overlay:not(.enabled)`
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbGoToEnd(page);
 | 
				
			||||||
          await page.keyboard.press("End");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await page.waitForFunction(
 | 
					          await page.waitForFunction(
 | 
				
			||||||
            sel =>
 | 
					            sel =>
 | 
				
			||||||
              document.getSelection().anchorOffset ===
 | 
					              document.getSelection().anchorOffset ===
 | 
				
			||||||
@ -1113,19 +1109,14 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          await switchToFreeText(page);
 | 
					          await switchToFreeText(page);
 | 
				
			||||||
          await page.focus(".annotationEditorLayer");
 | 
					          await page.focus(".annotationEditorLayer");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // Undo.
 | 
					          await kbUndo(page);
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					 | 
				
			||||||
          await page.keyboard.press("z");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await waitForSerialized(page, 0);
 | 
					          await waitForSerialized(page, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          editorIds = await getEditors(page, "freeText");
 | 
					          editorIds = await getEditors(page, "freeText");
 | 
				
			||||||
          expect(editorIds.length).withContext(`In ${browserName}`).toEqual(6);
 | 
					          expect(editorIds.length).withContext(`In ${browserName}`).toEqual(6);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // Undo again.
 | 
					          // Undo again.
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbUndo(page);
 | 
				
			||||||
          await page.keyboard.press("z");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          // Nothing should happen, it's why we can't wait for something
 | 
					          // Nothing should happen, it's why we can't wait for something
 | 
				
			||||||
          // specific!
 | 
					          // specific!
 | 
				
			||||||
          await page.waitForTimeout(200);
 | 
					          await page.waitForTimeout(200);
 | 
				
			||||||
@ -1224,10 +1215,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          await switchToFreeText(page);
 | 
					          await switchToFreeText(page);
 | 
				
			||||||
          await page.focus(".annotationEditorLayer");
 | 
					          await page.focus(".annotationEditorLayer");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // Undo.
 | 
					          await kbUndo(page);
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					 | 
				
			||||||
          await page.keyboard.press("z");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await waitForSerialized(page, 0);
 | 
					          await waitForSerialized(page, 0);
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
@ -1322,7 +1310,11 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
    it("must not remove an empty annotation", async () => {
 | 
					    it("must not remove an empty annotation", async () => {
 | 
				
			||||||
      await Promise.all(
 | 
					      await Promise.all(
 | 
				
			||||||
        pages.map(async ([browserName, page]) => {
 | 
					        pages.map(async ([browserName, page]) => {
 | 
				
			||||||
          await page.hover("[data-annotation-id='23R']");
 | 
					          await page.waitForSelector("[data-annotation-id='23R']");
 | 
				
			||||||
 | 
					          // Cannot use page.hover with Firefox on Mac because of a bug.
 | 
				
			||||||
 | 
					          // TODO: remove this when we switch to BiDi.
 | 
				
			||||||
 | 
					          await hover(page, "[data-annotation-id='23R']");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // Wait for the popup to be displayed.
 | 
					          // Wait for the popup to be displayed.
 | 
				
			||||||
          await page.waitForFunction(
 | 
					          await page.waitForFunction(
 | 
				
			||||||
            () =>
 | 
					            () =>
 | 
				
			||||||
@ -1341,7 +1333,8 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
            `.annotationEditorLayer:not(.freetextEditing)`
 | 
					            `.annotationEditorLayer:not(.freetextEditing)`
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.hover("[data-annotation-id='23R']");
 | 
					          // TODO: remove this when we switch to BiDi.
 | 
				
			||||||
 | 
					          await hover(page, "[data-annotation-id='23R']");
 | 
				
			||||||
          // Wait for the popup to be displayed.
 | 
					          // Wait for the popup to be displayed.
 | 
				
			||||||
          await page.waitForFunction(
 | 
					          await page.waitForFunction(
 | 
				
			||||||
            () =>
 | 
					            () =>
 | 
				
			||||||
@ -1592,11 +1585,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
    let pages;
 | 
					    let pages;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    beforeAll(async () => {
 | 
					    beforeAll(async () => {
 | 
				
			||||||
      pages = await loadAndWait(
 | 
					      pages = await loadAndWait("issue16633.pdf", ".annotationEditorLayer");
 | 
				
			||||||
        "issue16633.pdf",
 | 
					 | 
				
			||||||
        ".annotationEditorLayer",
 | 
					 | 
				
			||||||
        100
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    afterAll(async () => {
 | 
					    afterAll(async () => {
 | 
				
			||||||
@ -1944,10 +1933,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          );
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.focus("#editorFreeTextColor");
 | 
					          await page.focus("#editorFreeTextColor");
 | 
				
			||||||
 | 
					          await kbUndo(page);
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					 | 
				
			||||||
          await page.keyboard.press("z");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.waitForFunction(
 | 
					          await page.waitForFunction(
 | 
				
			||||||
            sel => !document.querySelector(sel),
 | 
					            sel => !document.querySelector(sel),
 | 
				
			||||||
@ -1955,9 +1941,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
            getEditorSelector(0)
 | 
					            getEditorSelector(0)
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbRedo(page);
 | 
				
			||||||
          await page.keyboard.press("y");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await page.waitForFunction(
 | 
					          await page.waitForFunction(
 | 
				
			||||||
            sel => !!document.querySelector(sel),
 | 
					            sel => !!document.querySelector(sel),
 | 
				
			||||||
            {},
 | 
					            {},
 | 
				
			||||||
@ -2046,9 +2030,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
            .toEqual(Math.round(pageY - 20));
 | 
					            .toEqual(Math.round(pageY - 20));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          for (let i = 0; i < 2; i++) {
 | 
					          for (let i = 0; i < 2; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveLeft(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowLeft");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -2062,9 +2044,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
            .toEqual(Math.round(pageY - 20));
 | 
					            .toEqual(Math.round(pageY - 20));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          for (let i = 0; i < 2; i++) {
 | 
					          for (let i = 0; i < 2; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveUp(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowUp");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -2164,9 +2144,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          for (let i = 0; i < 2; i++) {
 | 
					          for (let i = 0; i < 2; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveDown(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowDown");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -2178,25 +2156,19 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          for (let i = 0; i < 2; i++) {
 | 
					          for (let i = 0; i < 2; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveUp(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowUp");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          for (let i = 0; i < 2; i++) {
 | 
					          for (let i = 0; i < 2; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveRight(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowRight");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          for (let i = 0; i < 2; i++) {
 | 
					          for (let i = 0; i < 2; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveLeft(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowLeft");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -2342,7 +2314,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
            `${getEditorSelector(1)} .overlay.enabled`
 | 
					            `${getEditorSelector(1)} .overlay.enabled`
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.mouse.click(rect.x + 115, rect.y + 155);
 | 
					          await page.mouse.click(rect.x + 111, rect.y + 151);
 | 
				
			||||||
          await waitForSelectedEditor(page, getEditorSelector(1));
 | 
					          await waitForSelectedEditor(page, getEditorSelector(1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          const pos = n =>
 | 
					          const pos = n =>
 | 
				
			||||||
@ -2361,12 +2333,21 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
            .withContext(`In ${browserName}`)
 | 
					            .withContext(`In ${browserName}`)
 | 
				
			||||||
            .toEqual(1);
 | 
					            .toEqual(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          const getY = selector =>
 | 
				
			||||||
 | 
					            page.evaluate(
 | 
				
			||||||
 | 
					              sel => document.querySelector(sel).getBoundingClientRect().y,
 | 
				
			||||||
 | 
					              selector
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					          const height = await page.evaluate(
 | 
				
			||||||
 | 
					            sel => document.querySelector(sel).getBoundingClientRect().height,
 | 
				
			||||||
 | 
					            getEditorSelector(0)
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          const y0 = await getY(getEditorSelector(0));
 | 
				
			||||||
          const selectorEditor = getEditorSelector(1);
 | 
					          const selectorEditor = getEditorSelector(1);
 | 
				
			||||||
          let xy = await getXY(page, selectorEditor);
 | 
					          let xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          for (let i = 0; i < 6; i++) {
 | 
					          while ((await getY(selectorEditor)) > y0 - height) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveUp(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowUp");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -2448,12 +2429,12 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
              return { x, y };
 | 
					              return { x, y };
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
            const oldPos = allPositions[i];
 | 
					            const oldPos = allPositions[i];
 | 
				
			||||||
            expect(Math.round(pos.x - oldPos.x))
 | 
					            expect(Math.abs(Math.round(pos.x - oldPos.x) - 39))
 | 
				
			||||||
              .withContext(`In ${browserName}`)
 | 
					              .withContext(`In ${browserName}`)
 | 
				
			||||||
              .toEqual(39);
 | 
					              .toBeLessThanOrEqual(1);
 | 
				
			||||||
            expect(Math.round(pos.y - oldPos.y))
 | 
					            expect(Math.abs(Math.round(pos.y - oldPos.y) - 74))
 | 
				
			||||||
              .withContext(`In ${browserName}`)
 | 
					              .withContext(`In ${browserName}`)
 | 
				
			||||||
              .toEqual(74);
 | 
					              .toBeLessThanOrEqual(1);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
@ -2505,6 +2486,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
            visible: true,
 | 
					            visible: true,
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
          await page.type(`${getEditorSelector(0)} .internal`, data);
 | 
					          await page.type(`${getEditorSelector(0)} .internal`, data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // Commit.
 | 
					          // Commit.
 | 
				
			||||||
          await page.keyboard.press("Escape");
 | 
					          await page.keyboard.press("Escape");
 | 
				
			||||||
          await page.waitForSelector(
 | 
					          await page.waitForSelector(
 | 
				
			||||||
@ -2669,7 +2651,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          );
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // Go to the last page.
 | 
					          // Go to the last page.
 | 
				
			||||||
          await page.keyboard.press("End");
 | 
					          await kbGoToEnd(page);
 | 
				
			||||||
          await page.waitForSelector(
 | 
					          await page.waitForSelector(
 | 
				
			||||||
            `.page[data-page-number = "14"] > .annotationEditorLayer.freetextEditing`,
 | 
					            `.page[data-page-number = "14"] > .annotationEditorLayer.freetextEditing`,
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@ -2681,7 +2663,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          await clearAll(page);
 | 
					          await clearAll(page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // Go to the first page.
 | 
					          // Go to the first page.
 | 
				
			||||||
          await page.keyboard.press("Home");
 | 
					          await kbGoToBegin(page);
 | 
				
			||||||
          await page.waitForSelector(page1Selector, {
 | 
					          await page.waitForSelector(page1Selector, {
 | 
				
			||||||
            visible: true,
 | 
					            visible: true,
 | 
				
			||||||
            timeout: 0,
 | 
					            timeout: 0,
 | 
				
			||||||
@ -2690,10 +2672,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
          // Make sure that nothing has be added.
 | 
					          // Make sure that nothing has be added.
 | 
				
			||||||
          await waitForStorageEntries(page, 0);
 | 
					          await waitForStorageEntries(page, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // Undo.
 | 
					          await kbUndo(page);
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					 | 
				
			||||||
          await page.keyboard.press("z");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await waitForSerialized(page, 1);
 | 
					          await waitForSerialized(page, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.waitForSelector(getEditorSelector(0), {
 | 
					          await page.waitForSelector(getEditorSelector(0), {
 | 
				
			||||||
@ -2832,9 +2811,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
          let xy = await getXY(page, selectorEditor);
 | 
					          let xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          for (let i = 0; i < 5; i++) {
 | 
					          for (let i = 0; i < 5; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveUp(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowUp");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -2867,9 +2844,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
          xy = await getXY(page, selectorEditor);
 | 
					          xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          for (let i = 0; i < 5; i++) {
 | 
					          for (let i = 0; i < 5; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveDown(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowDown");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -2904,9 +2879,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
          let xy = await getXY(page, selectorEditor);
 | 
					          let xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          for (let i = 0; i < 10; i++) {
 | 
					          for (let i = 0; i < 10; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveLeft(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowLeft");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -2936,9 +2909,7 @@ describe("FreeText Editor", () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
          xy = await getXY(page, selectorEditor);
 | 
					          xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          for (let i = 0; i < 10; i++) {
 | 
					          for (let i = 0; i < 10; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveRight(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowRight");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForPositionChange(page, selectorEditor, xy);
 | 
					            await waitForPositionChange(page, selectorEditor, xy);
 | 
				
			||||||
            xy = await getXY(page, selectorEditor);
 | 
					            xy = await getXY(page, selectorEditor);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
				
			|||||||
@ -16,6 +16,9 @@
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
  closePages,
 | 
					  closePages,
 | 
				
			||||||
  getSelectedEditors,
 | 
					  getSelectedEditors,
 | 
				
			||||||
 | 
					  kbRedo,
 | 
				
			||||||
 | 
					  kbSelectAll,
 | 
				
			||||||
 | 
					  kbUndo,
 | 
				
			||||||
  loadAndWait,
 | 
					  loadAndWait,
 | 
				
			||||||
  waitForStorageEntries,
 | 
					  waitForStorageEntries,
 | 
				
			||||||
} from "./test_utils.mjs";
 | 
					} from "./test_utils.mjs";
 | 
				
			||||||
@ -29,9 +32,7 @@ const waitForPointerUp = page =>
 | 
				
			|||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const selectAll = async page => {
 | 
					const selectAll = async page => {
 | 
				
			||||||
  await page.keyboard.down("Control");
 | 
					  await kbSelectAll(page);
 | 
				
			||||||
  await page.keyboard.press("a");
 | 
					 | 
				
			||||||
  await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
  await page.waitForFunction(
 | 
					  await page.waitForFunction(
 | 
				
			||||||
    () => !document.querySelector(".inkEditor.disabled:not(.selectedEditor)")
 | 
					    () => !document.querySelector(".inkEditor.disabled:not(.selectedEditor)")
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
@ -39,9 +40,7 @@ const selectAll = async page => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const clearAll = async page => {
 | 
					const clearAll = async page => {
 | 
				
			||||||
  await selectAll(page);
 | 
					  await selectAll(page);
 | 
				
			||||||
  await page.keyboard.down("Control");
 | 
					 | 
				
			||||||
  await page.keyboard.press("Backspace");
 | 
					  await page.keyboard.press("Backspace");
 | 
				
			||||||
  await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
  await waitForStorageEntries(page, 0);
 | 
					  await waitForStorageEntries(page, 0);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -89,9 +88,7 @@ describe("Ink Editor", () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
          await clearAll(page);
 | 
					          await clearAll(page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbUndo(page);
 | 
				
			||||||
          await page.keyboard.press("z");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await waitForStorageEntries(page, 3);
 | 
					          await waitForStorageEntries(page, 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          expect(await getSelectedEditors(page))
 | 
					          expect(await getSelectedEditors(page))
 | 
				
			||||||
@ -130,16 +127,9 @@ describe("Ink Editor", () => {
 | 
				
			|||||||
          });
 | 
					          });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          for (let i = 0; i < 30; i++) {
 | 
					          for (let i = 0; i < 30; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbUndo(page);
 | 
				
			||||||
            await page.keyboard.press("z");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            await waitForStorageEntries(page, 0);
 | 
					            await waitForStorageEntries(page, 0);
 | 
				
			||||||
 | 
					            await kbRedo(page);
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					 | 
				
			||||||
            await page.keyboard.press("y");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            await waitForStorageEntries(page, 1);
 | 
					            await waitForStorageEntries(page, 1);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,8 @@ import {
 | 
				
			|||||||
  getFirstSerialized,
 | 
					  getFirstSerialized,
 | 
				
			||||||
  getQuerySelector,
 | 
					  getQuerySelector,
 | 
				
			||||||
  getSelector,
 | 
					  getSelector,
 | 
				
			||||||
 | 
					  kbDeleteLastWord,
 | 
				
			||||||
 | 
					  kbSelectAll,
 | 
				
			||||||
  loadAndWait,
 | 
					  loadAndWait,
 | 
				
			||||||
  scrollIntoView,
 | 
					  scrollIntoView,
 | 
				
			||||||
} from "./test_utils.mjs";
 | 
					} from "./test_utils.mjs";
 | 
				
			||||||
@ -1228,9 +1230,7 @@ describe("Interaction", () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
          await page.type(getSelector("27R"), " ", { delay: 200 });
 | 
					          await page.type(getSelector("27R"), " ", { delay: 200 });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbDeleteLastWord(page);
 | 
				
			||||||
          await page.keyboard.press("Backspace");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.waitForFunction(
 | 
					          await page.waitForFunction(
 | 
				
			||||||
            `${getQuerySelector("27R")}.value !== "HELLO WORDL "`
 | 
					            `${getQuerySelector("27R")}.value !== "HELLO WORDL "`
 | 
				
			||||||
@ -1654,9 +1654,7 @@ describe("Interaction", () => {
 | 
				
			|||||||
          value = await page.$eval(getSelector("28R"), el => el.value);
 | 
					          value = await page.$eval(getSelector("28R"), el => el.value);
 | 
				
			||||||
          expect(value).withContext(`In ${browserName}`).toEqual("abcdef");
 | 
					          expect(value).withContext(`In ${browserName}`).toEqual("abcdef");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbSelectAll(page);
 | 
				
			||||||
          await page.keyboard.press("A");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await page.keyboard.press("Backspace");
 | 
					          await page.keyboard.press("Backspace");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.keyboard.press("Enter");
 | 
					          await page.keyboard.press("Enter");
 | 
				
			||||||
@ -1962,9 +1960,7 @@ describe("Interaction", () => {
 | 
				
			|||||||
          await page.waitForTimeout(10);
 | 
					          await page.waitForTimeout(10);
 | 
				
			||||||
          await page.click(getSelector("26R"));
 | 
					          await page.click(getSelector("26R"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.keyboard.down("Control");
 | 
					          await kbSelectAll(page);
 | 
				
			||||||
          await page.keyboard.press("A");
 | 
					 | 
				
			||||||
          await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
          await page.keyboard.press("Backspace");
 | 
					          await page.keyboard.press("Backspace");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          await page.click(getSelector("23R"));
 | 
					          await page.click(getSelector("23R"));
 | 
				
			||||||
 | 
				
			|||||||
@ -18,6 +18,10 @@ import {
 | 
				
			|||||||
  getEditorDimensions,
 | 
					  getEditorDimensions,
 | 
				
			||||||
  getEditorSelector,
 | 
					  getEditorSelector,
 | 
				
			||||||
  getFirstSerialized,
 | 
					  getFirstSerialized,
 | 
				
			||||||
 | 
					  kbBigMoveDown,
 | 
				
			||||||
 | 
					  kbBigMoveRight,
 | 
				
			||||||
 | 
					  kbPaste,
 | 
				
			||||||
 | 
					  kbSelectAll,
 | 
				
			||||||
  loadAndWait,
 | 
					  loadAndWait,
 | 
				
			||||||
  serializeBitmapDimensions,
 | 
					  serializeBitmapDimensions,
 | 
				
			||||||
  waitForAnnotationEditorLayer,
 | 
					  waitForAnnotationEditorLayer,
 | 
				
			||||||
@ -31,9 +35,7 @@ import path from "path";
 | 
				
			|||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
 | 
					const __dirname = path.dirname(fileURLToPath(import.meta.url));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const selectAll = async page => {
 | 
					const selectAll = async page => {
 | 
				
			||||||
  await page.keyboard.down("Control");
 | 
					  await kbSelectAll(page);
 | 
				
			||||||
  await page.keyboard.press("a");
 | 
					 | 
				
			||||||
  await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
  await page.waitForFunction(
 | 
					  await page.waitForFunction(
 | 
				
			||||||
    () => !document.querySelector(".stampEditor:not(.selectedEditor)")
 | 
					    () => !document.querySelector(".stampEditor:not(.selectedEditor)")
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
@ -41,9 +43,7 @@ const selectAll = async page => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const clearAll = async page => {
 | 
					const clearAll = async page => {
 | 
				
			||||||
  await selectAll(page);
 | 
					  await selectAll(page);
 | 
				
			||||||
  await page.keyboard.down("Control");
 | 
					 | 
				
			||||||
  await page.keyboard.press("Backspace");
 | 
					  await page.keyboard.press("Backspace");
 | 
				
			||||||
  await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
  await waitForStorageEntries(page, 0);
 | 
					  await waitForStorageEntries(page, 0);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -101,9 +101,7 @@ const copyImage = async (page, imagePath, number) => {
 | 
				
			|||||||
          })
 | 
					          })
 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
    ]);
 | 
					    ]);
 | 
				
			||||||
    await page.keyboard.down("Control");
 | 
					    await kbPaste(page);
 | 
				
			||||||
    await page.keyboard.press("v");
 | 
					 | 
				
			||||||
    await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
    hasPasteEvent = await promise;
 | 
					    hasPasteEvent = await promise;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -521,9 +519,7 @@ describe("Stamp Editor", () => {
 | 
				
			|||||||
            .toEqual(true);
 | 
					            .toEqual(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          for (let i = 0; i < 4; i++) {
 | 
					          for (let i = 0; i < 4; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveRight(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowRight");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForDimsChange(prevWidth, prevHeight);
 | 
					            await waitForDimsChange(prevWidth, prevHeight);
 | 
				
			||||||
            [prevWidth, prevHeight] = await getDims();
 | 
					            [prevWidth, prevHeight] = await getDims();
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -554,9 +550,7 @@ describe("Stamp Editor", () => {
 | 
				
			|||||||
            .toEqual(true);
 | 
					            .toEqual(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          for (let i = 0; i < 4; i++) {
 | 
					          for (let i = 0; i < 4; i++) {
 | 
				
			||||||
            await page.keyboard.down("Control");
 | 
					            await kbBigMoveDown(page);
 | 
				
			||||||
            await page.keyboard.press("ArrowDown");
 | 
					 | 
				
			||||||
            await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
            await waitForDimsChange(prevWidth, prevHeight);
 | 
					            await waitForDimsChange(prevWidth, prevHeight);
 | 
				
			||||||
            [prevWidth, prevHeight] = await getDims();
 | 
					            [prevWidth, prevHeight] = await getDims();
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
				
			|||||||
@ -13,6 +13,9 @@
 | 
				
			|||||||
 * limitations under the License.
 | 
					 * limitations under the License.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import os from "os";
 | 
				
			||||||
 | 
					const isMac = os.platform() === "darwin";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function loadAndWait(filename, selector, zoom, pageSetup) {
 | 
					function loadAndWait(filename, selector, zoom, pageSetup) {
 | 
				
			||||||
  return Promise.all(
 | 
					  return Promise.all(
 | 
				
			||||||
    global.integrationSessions.map(async session => {
 | 
					    global.integrationSessions.map(async session => {
 | 
				
			||||||
@ -33,10 +36,10 @@ function loadAndWait(filename, selector, zoom, pageSetup) {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let url = `${global.integrationBaseUrl}?file=/test/pdfs/${filename}`;
 | 
					      const url = `${
 | 
				
			||||||
      if (zoom) {
 | 
					        global.integrationBaseUrl
 | 
				
			||||||
        url += `#zoom=${zoom}`;
 | 
					      }?file=/test/pdfs/${filename}#zoom=${zoom ?? "page-fit"}`;
 | 
				
			||||||
      }
 | 
					
 | 
				
			||||||
      await page.goto(url);
 | 
					      await page.goto(url);
 | 
				
			||||||
      if (pageSetup) {
 | 
					      if (pageSetup) {
 | 
				
			||||||
        await pageSetup(page);
 | 
					        await pageSetup(page);
 | 
				
			||||||
@ -63,9 +66,7 @@ function closePages(pages) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
async function clearInput(page, selector) {
 | 
					async function clearInput(page, selector) {
 | 
				
			||||||
  await page.click(selector);
 | 
					  await page.click(selector);
 | 
				
			||||||
  await page.keyboard.down("Control");
 | 
					  await kbSelectAll(page);
 | 
				
			||||||
  await page.keyboard.press("A");
 | 
					 | 
				
			||||||
  await page.keyboard.up("Control");
 | 
					 | 
				
			||||||
  await page.keyboard.press("Backspace");
 | 
					  await page.keyboard.press("Backspace");
 | 
				
			||||||
  await page.waitForTimeout(10);
 | 
					  await page.waitForTimeout(10);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -285,6 +286,137 @@ async function scrollIntoView(page, selector) {
 | 
				
			|||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function hover(page, selector) {
 | 
				
			||||||
 | 
					  const rect = await page.$eval(selector, el => {
 | 
				
			||||||
 | 
					    const { x, y, width, height } = el.getBoundingClientRect();
 | 
				
			||||||
 | 
					    return { x, y, width, height };
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					  await page.mouse.move(rect.x + rect.width / 2, rect.y + rect.height / 2);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const modifier = isMac ? "Meta" : "Control";
 | 
				
			||||||
 | 
					async function kbCopy(page) {
 | 
				
			||||||
 | 
					  await page.keyboard.down(modifier);
 | 
				
			||||||
 | 
					  await page.keyboard.press("c", { commands: ["Copy"] });
 | 
				
			||||||
 | 
					  await page.keyboard.up(modifier);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbPaste(page) {
 | 
				
			||||||
 | 
					  await page.keyboard.down(modifier);
 | 
				
			||||||
 | 
					  await page.keyboard.press("v", { commands: ["Paste"] });
 | 
				
			||||||
 | 
					  await page.keyboard.up(modifier);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbUndo(page) {
 | 
				
			||||||
 | 
					  await page.keyboard.down(modifier);
 | 
				
			||||||
 | 
					  await page.keyboard.press("z");
 | 
				
			||||||
 | 
					  await page.keyboard.up(modifier);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbRedo(page) {
 | 
				
			||||||
 | 
					  if (isMac) {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Meta");
 | 
				
			||||||
 | 
					    await page.keyboard.down("Shift");
 | 
				
			||||||
 | 
					    await page.keyboard.press("z");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Shift");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Meta");
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Control");
 | 
				
			||||||
 | 
					    await page.keyboard.press("y");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Control");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbSelectAll(page) {
 | 
				
			||||||
 | 
					  await page.keyboard.down(modifier);
 | 
				
			||||||
 | 
					  await page.keyboard.press("a", { commands: ["SelectAll"] });
 | 
				
			||||||
 | 
					  await page.keyboard.up(modifier);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbModifierDown(page) {
 | 
				
			||||||
 | 
					  await page.keyboard.down(modifier);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbModifierUp(page) {
 | 
				
			||||||
 | 
					  await page.keyboard.up(modifier);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbGoToEnd(page) {
 | 
				
			||||||
 | 
					  if (isMac) {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Meta");
 | 
				
			||||||
 | 
					    await page.keyboard.press("ArrowDown", {
 | 
				
			||||||
 | 
					      commands: ["MoveToEndOfDocument"],
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    await page.keyboard.up("Meta");
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Control");
 | 
				
			||||||
 | 
					    await page.keyboard.press("End");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Control");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbGoToBegin(page) {
 | 
				
			||||||
 | 
					  if (isMac) {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Meta");
 | 
				
			||||||
 | 
					    await page.keyboard.press("ArrowUp", {
 | 
				
			||||||
 | 
					      commands: ["MoveToBeginningOfDocument"],
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    await page.keyboard.up("Meta");
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Control");
 | 
				
			||||||
 | 
					    await page.keyboard.press("Home");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Control");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbBigMoveLeft(page) {
 | 
				
			||||||
 | 
					  if (isMac) {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Shift");
 | 
				
			||||||
 | 
					    await page.keyboard.press("ArrowLeft");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Shift");
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Control");
 | 
				
			||||||
 | 
					    await page.keyboard.press("ArrowLeft");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Control");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbBigMoveRight(page) {
 | 
				
			||||||
 | 
					  if (isMac) {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Shift");
 | 
				
			||||||
 | 
					    await page.keyboard.press("ArrowRight");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Shift");
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Control");
 | 
				
			||||||
 | 
					    await page.keyboard.press("ArrowRight");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Control");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbBigMoveUp(page) {
 | 
				
			||||||
 | 
					  if (isMac) {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Shift");
 | 
				
			||||||
 | 
					    await page.keyboard.press("ArrowUp");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Shift");
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Control");
 | 
				
			||||||
 | 
					    await page.keyboard.press("ArrowUp");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Control");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					async function kbBigMoveDown(page) {
 | 
				
			||||||
 | 
					  if (isMac) {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Shift");
 | 
				
			||||||
 | 
					    await page.keyboard.press("ArrowDown");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Shift");
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Control");
 | 
				
			||||||
 | 
					    await page.keyboard.press("ArrowDown");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Control");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function kbDeleteLastWord(page) {
 | 
				
			||||||
 | 
					  if (isMac) {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Alt");
 | 
				
			||||||
 | 
					    await page.keyboard.press("Backspace");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Alt");
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    await page.keyboard.down("Control");
 | 
				
			||||||
 | 
					    await page.keyboard.press("Backspace");
 | 
				
			||||||
 | 
					    await page.keyboard.up("Control");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export {
 | 
					export {
 | 
				
			||||||
  clearInput,
 | 
					  clearInput,
 | 
				
			||||||
  closePages,
 | 
					  closePages,
 | 
				
			||||||
@ -298,6 +430,21 @@ export {
 | 
				
			|||||||
  getSelectedEditors,
 | 
					  getSelectedEditors,
 | 
				
			||||||
  getSelector,
 | 
					  getSelector,
 | 
				
			||||||
  getSerialized,
 | 
					  getSerialized,
 | 
				
			||||||
 | 
					  hover,
 | 
				
			||||||
 | 
					  kbBigMoveDown,
 | 
				
			||||||
 | 
					  kbBigMoveLeft,
 | 
				
			||||||
 | 
					  kbBigMoveRight,
 | 
				
			||||||
 | 
					  kbBigMoveUp,
 | 
				
			||||||
 | 
					  kbCopy,
 | 
				
			||||||
 | 
					  kbDeleteLastWord,
 | 
				
			||||||
 | 
					  kbGoToBegin,
 | 
				
			||||||
 | 
					  kbGoToEnd,
 | 
				
			||||||
 | 
					  kbModifierDown,
 | 
				
			||||||
 | 
					  kbModifierUp,
 | 
				
			||||||
 | 
					  kbPaste,
 | 
				
			||||||
 | 
					  kbRedo,
 | 
				
			||||||
 | 
					  kbSelectAll,
 | 
				
			||||||
 | 
					  kbUndo,
 | 
				
			||||||
  loadAndWait,
 | 
					  loadAndWait,
 | 
				
			||||||
  mockClipboard,
 | 
					  mockClipboard,
 | 
				
			||||||
  scrollIntoView,
 | 
					  scrollIntoView,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user