From db060110327e3185fc37cc19b70513f86dc114cc Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 18 Aug 2024 15:21:02 +0200 Subject: [PATCH] [Editor] Move setting `window.uiManager` back to the test code In PR #18574 setting `window.uiManager` was moved into the `src` folder to avoid intermittent integration test failures because at the time we lacked a way to register event listeners early (before PDF.js loads). However, in PR #18617 this functionality got introduced, so we can now use the new way of setting up the event bus in the tests to move this back to the `test` folder again and to reduce the amount of test-only code in the main codebase as discussed in PR #18574. Partially reverts e037c5711d3d2413669e9b6c275986adf24a295b. --- src/display/editor/tools.js | 1 - test/integration/highlight_editor_spec.mjs | 8 +++++++- test/integration/stamp_editor_spec.mjs | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index e17b1bfb97775..e266ab18972d8 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -806,7 +806,6 @@ class AnnotationEditorUIManager { this.isShiftKeyDown = false; if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) { - window.uiManager = this; Object.defineProperty(this, "reset", { value: () => { this.selectAll(); diff --git a/test/integration/highlight_editor_spec.mjs b/test/integration/highlight_editor_spec.mjs index 5533d37a9c307..e793ec825b198 100644 --- a/test/integration/highlight_editor_spec.mjs +++ b/test/integration/highlight_editor_spec.mjs @@ -990,7 +990,13 @@ describe("Highlight Editor", () => { "tracemonkey.pdf", ".annotationEditorLayer", null, - null, + { + eventBusSetup: eventBus => { + eventBus.on("annotationeditoruimanager", ({ uiManager }) => { + window.uiManager = uiManager; + }); + }, + }, { highlightEditorColors: "red=#AB0000", supportsCaretBrowsingMode: true, diff --git a/test/integration/stamp_editor_spec.mjs b/test/integration/stamp_editor_spec.mjs index 9da7bdc4b38f8..c947d934003ad 100644 --- a/test/integration/stamp_editor_spec.mjs +++ b/test/integration/stamp_editor_spec.mjs @@ -832,7 +832,13 @@ describe("Stamp Editor", () => { "empty.pdf", ".annotationEditorLayer", null, - null, + { + eventBusSetup: eventBus => { + eventBus.on("annotationeditoruimanager", ({ uiManager }) => { + window.uiManager = uiManager; + }); + }, + }, { enableAltText: true, enableUpdatedAddImage: true,