From 2ff904fb2bd5d2787375845d21791cf6a4c6c06f Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 18 Nov 2022 23:08:11 +0100 Subject: [PATCH] Add localization support for the `annotationLayer` reference tests (issue 10791) --- test/driver.js | 17 ++++++++++++----- test/test_slave.html | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/test/driver.js b/test/driver.js index f63c12abc..e25a01456 100644 --- a/test/driver.js +++ b/test/driver.js @@ -27,7 +27,8 @@ const { shadow, XfaLayer, } = pdfjsLib; -const { parseQueryString, SimpleLinkService } = pdfjsViewer; +const { GenericL10n, NullL10n, parseQueryString, SimpleLinkService } = + pdfjsViewer; const WAITING_TIME = 100; // ms const CMAP_URL = "/build/generic/web/cmaps/"; @@ -35,6 +36,7 @@ const CMAP_PACKED = true; const STANDARD_FONT_DATA_URL = "/build/generic/web/standard_fonts/"; const IMAGE_RESOURCES_PATH = "/web/images/"; const VIEWER_CSS = "../build/components/pdf_viewer.css"; +const VIEWER_LOCALE = "en-US"; const WORKER_SRC = "../build/generic/build/pdf.worker.js"; const RENDER_TASK_ON_CONTINUE_DELAY = 5; // ms const SVG_NS = "http://www.w3.org/2000/svg"; @@ -203,7 +205,8 @@ class Rasterize { annotationCanvasMap, page, imageResourcesPath, - renderForms = false + renderForms = false, + l10n = NullL10n ) { try { const { svg, foreignObject, style, div } = this.createContainer(viewport); @@ -232,6 +235,7 @@ class Rasterize { annotationCanvasMap: annotationImageMap, }; AnnotationLayer.render(parameters); + await l10n.translate(div); // Inline SVG images from text annotations. await inlineImages(div); @@ -324,6 +328,8 @@ class Driver { // Configure the global worker options. GlobalWorkerOptions.workerSrc = WORKER_SRC; + this._l10n = new GenericL10n(VIEWER_LOCALE); + // Set the passed options this.inflight = options.inflight; this.disableScrolling = options.disableScrolling; @@ -794,7 +800,7 @@ class Driver { this._snapshot(task, error); }; initPromise - .then(function (data) { + .then(data => { const renderTask = page.render(renderContext); if (task.renderTaskOnContinue) { @@ -803,7 +809,7 @@ class Driver { setTimeout(cont, RENDER_TASK_ON_CONTINUE_DELAY); }; } - return renderTask.promise.then(function () { + return renderTask.promise.then(() => { if (annotationCanvasMap) { Rasterize.annotationLayer( annotationLayerContext, @@ -813,7 +819,8 @@ class Driver { annotationCanvasMap, page, IMAGE_RESOURCES_PATH, - renderForms + renderForms, + this._l10n ).then(() => { completeRender(false); }); diff --git a/test/test_slave.html b/test/test_slave.html index 37b166854..4010795ec 100644 --- a/test/test_slave.html +++ b/test/test_slave.html @@ -21,6 +21,8 @@ limitations under the License. + +

Inflight requests: