Merge pull request #17370 from calixteman/issue17368
[Editor] Make sure that all layers are disabled when an editing session is done
This commit is contained in:
		
						commit
						a3637e653f
					
				@ -146,6 +146,11 @@ class AnnotationEditorLayer {
 | 
				
			|||||||
  updateMode(mode = this.#uiManager.getMode()) {
 | 
					  updateMode(mode = this.#uiManager.getMode()) {
 | 
				
			||||||
    this.#cleanup();
 | 
					    this.#cleanup();
 | 
				
			||||||
    switch (mode) {
 | 
					    switch (mode) {
 | 
				
			||||||
 | 
					      case AnnotationEditorType.NONE:
 | 
				
			||||||
 | 
					        this.disableTextSelection();
 | 
				
			||||||
 | 
					        this.togglePointerEvents(false);
 | 
				
			||||||
 | 
					        this.disableClick();
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
      case AnnotationEditorType.INK:
 | 
					      case AnnotationEditorType.INK:
 | 
				
			||||||
        // We always want to have an ink editor ready to draw in.
 | 
					        // We always want to have an ink editor ready to draw in.
 | 
				
			||||||
        this.addInkEditorIfNeeded(false);
 | 
					        this.addInkEditorIfNeeded(false);
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,7 @@ import {
 | 
				
			|||||||
  kbSelectAll,
 | 
					  kbSelectAll,
 | 
				
			||||||
  kbUndo,
 | 
					  kbUndo,
 | 
				
			||||||
  loadAndWait,
 | 
					  loadAndWait,
 | 
				
			||||||
 | 
					  scrollIntoView,
 | 
				
			||||||
  waitForStorageEntries,
 | 
					  waitForStorageEntries,
 | 
				
			||||||
} from "./test_utils.mjs";
 | 
					} from "./test_utils.mjs";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -193,4 +194,66 @@ describe("Ink Editor", () => {
 | 
				
			|||||||
      );
 | 
					      );
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  describe("Invisible layers must be disabled", () => {
 | 
				
			||||||
 | 
					    let pages;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    beforeAll(async () => {
 | 
				
			||||||
 | 
					      pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    afterAll(async () => {
 | 
				
			||||||
 | 
					      await closePages(pages);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it("must check that the editor layer is disabled", async () => {
 | 
				
			||||||
 | 
					      await Promise.all(
 | 
				
			||||||
 | 
					        pages.map(async ([browserName, page]) => {
 | 
				
			||||||
 | 
					          await page.click("#editorInk");
 | 
				
			||||||
 | 
					          await page.waitForSelector(".annotationEditorLayer.inkEditing");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          const rect = await page.$eval(".annotationEditorLayer", el => {
 | 
				
			||||||
 | 
					            // With Chrome something is wrong when serializing a DomRect,
 | 
				
			||||||
 | 
					            // hence we extract the values and just return them.
 | 
				
			||||||
 | 
					            const { x, y } = el.getBoundingClientRect();
 | 
				
			||||||
 | 
					            return { x, y };
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          const x = rect.x + 20;
 | 
				
			||||||
 | 
					          const y = rect.y + 20;
 | 
				
			||||||
 | 
					          const clickPromise = waitForPointerUp(page);
 | 
				
			||||||
 | 
					          await page.mouse.move(x, y);
 | 
				
			||||||
 | 
					          await page.mouse.down();
 | 
				
			||||||
 | 
					          await page.mouse.move(x + 50, y + 50);
 | 
				
			||||||
 | 
					          await page.mouse.up();
 | 
				
			||||||
 | 
					          await clickPromise;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          await commit(page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          const oneToFourteen = Array.from(new Array(13).keys(), n => n + 2);
 | 
				
			||||||
 | 
					          for (const pageNumber of oneToFourteen) {
 | 
				
			||||||
 | 
					            await scrollIntoView(
 | 
				
			||||||
 | 
					              page,
 | 
				
			||||||
 | 
					              `.page[data-page-number = "${pageNumber}"]`
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          await page.click("#editorInk");
 | 
				
			||||||
 | 
					          await page.waitForSelector(".annotationEditorLayer:not(.inkEditing)");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          const fourteenToOne = Array.from(new Array(13).keys(), n => 13 - n);
 | 
				
			||||||
 | 
					          for (const pageNumber of fourteenToOne) {
 | 
				
			||||||
 | 
					            await scrollIntoView(
 | 
				
			||||||
 | 
					              page,
 | 
				
			||||||
 | 
					              `.page[data-page-number = "${pageNumber}"]`
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          await page.waitForSelector(
 | 
				
			||||||
 | 
					            `.page[data-page-number = "1"] .annotationEditorLayer.disabled:not(.inkEditing)`
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user