Compare commits

...

20 Commits

Author SHA1 Message Date
Tim van der Meij
2f7d163dfd
Merge pull request #19812 from timvandermeij/disable-permafail
Remove debug code from the integration tests, and skip the "must check that canvas perfectly fits the page whatever the zoom level" integration test in Chrome
2025-04-13 20:53:58 +02:00
Tim van der Meij
923753a66b
Skip the "must check that canvas perfectly fits the page whatever the zoom level" integration test in Chrome
This is a temporary measure to reduce noise until #19811 is fixed. Note
that this shouldn't be an issue in terms of coverage because we still
run the test in Firefox.
2025-04-13 19:32:39 +02:00
Tim van der Meij
efe4a3455a
Remove debug code from the integration tests
Doing so simplifies the code a bit, and such code is generally not
checked in because it can easily be added locally if needed.
2025-04-13 19:19:13 +02:00
Tim van der Meij
35f85c55bd
Merge pull request #19810 from Snuffleupagus/issue-19808
Update Webpack to version `5.99.5` (issue 19808)
2025-04-13 18:43:19 +02:00
Tim van der Meij
574e4f4ec1
Merge pull request #19809 from timvandermeij/integration-tests-isolate-all-and-random
Run the integration tests in a random order
2025-04-13 18:37:08 +02:00
Jonas Jenwald
6b961c424f Update Webpack to version 5.99.5 (issue 19808)
In Webpack version `5.99.0` the way that `export` statements are handled was changed slightly, with much less boilerplate code being generated, which unfortunately breaks our `tweakWebpackOutput` function that's used to expose the exported properties globally and that e.g. the viewer depends upon.

Given that we were depending on formatting that should most likely be viewed as nothing more than an internal implementation detail in Webpack, we instead work-around this by manually defining the structures that were previously generated.
Obviously this will lead to a tiny bit more manual work in the future, however we don't change the API-surface often enough that it should be a big issue *and* the relevant unit-tests are updated such that it shouldn't be possible to break this.

*NOTE:* In the future we might want to consider no longer using global properties like this, and instead rely only on proper `export`s throughout the code-base.
However changing this would likely be non-trivial (given edge-cases), and it'd be an `api-major` change, so let's just do the minimal amount of work to unblock Webpack updates for now.
2025-04-13 16:48:19 +02:00
Tim van der Meij
938430be5b
Remove workaround from the "must convert input to uppercase" scripting integration test
It's no longer necessary after commit 1c73e52 that caused the document
to be closed properly between tests, and this therefore partly reverts
commit 973b67f.
2025-04-13 15:57:54 +02:00
Tim van der Meij
5f46791887
Run the integration tests in a random order
This commit configures Jasmine to no longer run the tests in a fixed
order, which combined with the previous isolation commits avoids being
able to accidentally introduce dependencies between integration tests.
2025-04-13 15:46:03 +02:00
Tim van der Meij
75b321b000
Isolate the viewer integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:24:15 +02:00
Tim van der Meij
965949c259
Isolate the text layer integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:24:15 +02:00
Tim van der Meij
6308f5eb51
Isolate the text field integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:24:15 +02:00
Tim van der Meij
7c8262ccc9
Isolate the stamp editor integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:24:15 +02:00
Tim van der Meij
44243761a5
Isolate the highlight editor integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:20:27 +02:00
Tim van der Meij
5011d96a62
Isolate the freetext editor integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:20:23 +02:00
Tim van der Meij
f043760b54
Isolate the find integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:20:18 +02:00
Tim van der Meij
179859f54a
Isolate the copy/paste integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:20:14 +02:00
Tim van der Meij
0e9e4ec64f
Isolate the caret browsing integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:20:08 +02:00
Tim van der Meij
a60f9bc612
Isolate the autolinker integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:20:03 +02:00
Tim van der Meij
e1cbba4ded
Isolate the annotation integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:19:59 +02:00
Tim van der Meij
193bebd78a
Isolate the accessibility integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:18:19 +02:00
28 changed files with 477 additions and 449 deletions

View File

@ -362,10 +362,6 @@ function createWebpackConfig(
// V8 chokes on very long sequences, work around that.
sequences: false,
},
mangle: {
// Ensure that the `tweakWebpackOutput` function works.
reserved: ["__webpack_exports__"],
},
keep_classnames: true,
keep_fnames: true,
module: isModule,
@ -463,13 +459,6 @@ function checkChromePreferencesFile(chromePrefsPath, webPrefs) {
return ret;
}
function tweakWebpackOutput(jsName) {
return replace(
/((?:\s|,)__webpack_exports__)(?:\s?)=(?:\s?)({};)/gm,
(match, p1, p2) => `${p1} = globalThis.${jsName} = ${p2}`
);
}
function createMainBundle(defines) {
const mainFileConfig = createWebpackConfig(defines, {
filename: defines.MINIFIED ? "pdf.min.mjs" : "pdf.mjs",
@ -479,8 +468,7 @@ function createMainBundle(defines) {
});
return gulp
.src("./src/pdf.js", { encoding: false })
.pipe(webpack2Stream(mainFileConfig))
.pipe(tweakWebpackOutput("pdfjsLib"));
.pipe(webpack2Stream(mainFileConfig));
}
function createScriptingBundle(defines, extraOptions = undefined) {
@ -548,8 +536,7 @@ function createSandboxBundle(defines, extraOptions = undefined) {
return gulp
.src("./src/pdf.sandbox.js", { encoding: false })
.pipe(webpack2Stream(sandboxFileConfig))
.pipe(tweakWebpackOutput("pdfjsSandbox"));
.pipe(webpack2Stream(sandboxFileConfig));
}
function createWorkerBundle(defines) {
@ -561,8 +548,7 @@ function createWorkerBundle(defines) {
});
return gulp
.src("./src/pdf.worker.js", { encoding: false })
.pipe(webpack2Stream(workerFileConfig))
.pipe(tweakWebpackOutput("pdfjsWorker"));
.pipe(webpack2Stream(workerFileConfig));
}
function createWebBundle(defines, options) {
@ -610,8 +596,7 @@ function createComponentsBundle(defines) {
});
return gulp
.src("./web/pdf_viewer.component.js", { encoding: false })
.pipe(webpack2Stream(componentsFileConfig))
.pipe(tweakWebpackOutput("pdfjsViewer"));
.pipe(webpack2Stream(componentsFileConfig));
}
function createImageDecodersBundle(defines) {
@ -625,8 +610,7 @@ function createImageDecodersBundle(defines) {
});
return gulp
.src("./src/pdf.image_decoders.js", { encoding: false })
.pipe(webpack2Stream(componentsFileConfig))
.pipe(tweakWebpackOutput("pdfjsImageDecoders"));
.pipe(webpack2Stream(componentsFileConfig));
}
function createCMapBundle() {

8
package-lock.json generated
View File

@ -58,7 +58,7 @@
"ttest": "^4.0.0",
"typescript": "^5.8.3",
"vinyl": "^3.0.0",
"webpack": "^5.98.0",
"webpack": "^5.99.5",
"webpack-stream": "^7.0.0",
"yargs": "^17.7.2"
},
@ -12388,9 +12388,9 @@
}
},
"node_modules/webpack": {
"version": "5.98.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.98.0.tgz",
"integrity": "sha512-UFynvx+gM44Gv9qFgj0acCQK2VE1CtdfwFdimkapco3hlPCJ/zeq73n2yVKimVbtm+TnApIugGhLJnkU6gjYXA==",
"version": "5.99.5",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.99.5.tgz",
"integrity": "sha512-q+vHBa6H9qwBLUlHL4Y7L0L1/LlyBKZtS9FHNCQmtayxjI5RKC9yD8gpvLeqGv5lCQp1Re04yi0MF40pf30Pvg==",
"dev": true,
"license": "MIT",
"dependencies": {

View File

@ -53,7 +53,7 @@
"ttest": "^4.0.0",
"typescript": "^5.8.3",
"vinyl": "^3.0.0",
"webpack": "^5.98.0",
"webpack": "^5.99.5",
"webpack-stream": "^7.0.0",
"yargs": "^17.7.2"
},

View File

@ -2136,6 +2136,13 @@ class PDFWorker {
);
};
}
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
this._resetGlobalState = () => {
this.#isWorkerDisabled = false;
delete globalThis.pdfjsWorker;
};
}
}
constructor({

View File

@ -29,6 +29,18 @@ const pdfjsVersion =
const pdfjsBuild =
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0;
globalThis.pdfjsImageDecoders = {
getVerbosityLevel,
Jbig2Error,
Jbig2Image,
JpegError,
JpegImage,
JpxError,
JpxImage,
setVerbosityLevel,
VerbosityLevel,
};
export {
getVerbosityLevel,
Jbig2Error,

View File

@ -93,6 +93,59 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING || GENERIC")) {
};
}
globalThis.pdfjsLib = {
AbortException,
AnnotationEditorLayer,
AnnotationEditorParamsType,
AnnotationEditorType,
AnnotationEditorUIManager,
AnnotationLayer,
AnnotationMode,
AnnotationType,
build,
ColorPicker,
createValidAbsoluteUrl,
DOMSVGFactory,
DrawLayer,
FeatureTest,
fetchData,
getDocument,
getFilenameFromUrl,
getPdfFilenameFromUrl,
getUuid,
getXfaPageViewport,
GlobalWorkerOptions,
ImageKind,
InvalidPDFException,
isDataScheme,
isPdfFile,
isValidExplicitDest,
MathClamp,
noContextMenu,
normalizeUnicode,
OPS,
OutputScale,
PasswordResponses,
PDFDataRangeTransport,
PDFDateString,
PDFWorker,
PermissionFlag,
PixelsPerInch,
RenderingCancelledException,
ResponseException,
setLayerDimensions,
shadow,
SignatureExtractor,
stopEvent,
SupportedImageMimeTypes,
TextLayer,
TouchManager,
Util,
VerbosityLevel,
version,
XfaLayer,
};
export {
AbortException,
AnnotationEditorLayer,

View File

@ -145,4 +145,8 @@ function QuickJSSandbox() {
return ModuleLoader().then(module => new Sandbox(window, module));
}
globalThis.pdfjsSandbox = {
QuickJSSandbox,
};
export { QuickJSSandbox };

4
src/pdf.worker.js vendored
View File

@ -22,4 +22,8 @@ const pdfjsVersion =
const pdfjsBuild =
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0;
globalThis.pdfjsWorker = {
WorkerMessageHandler,
};
export { WorkerMessageHandler };

View File

@ -38,11 +38,11 @@ describe("accessibility", () => {
describe("structure tree", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("structure_simple.pdf", ".structTree");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -107,14 +107,14 @@ describe("accessibility", () => {
describe("Annotation", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey_a11y.pdf",
".textLayer .endOfContent"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -147,11 +147,11 @@ describe("accessibility", () => {
describe("Annotations order", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("fields_order.pdf", ".annotationLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -180,11 +180,11 @@ describe("accessibility", () => {
describe("Stamp annotation accessibility", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tagged_stamp.pdf", ".annotationLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -245,11 +245,11 @@ describe("accessibility", () => {
describe("Figure in the content stream", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1708040.pdf", ".textLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -25,14 +25,14 @@ describe("Annotation highlight", () => {
describe("annotation-highlight.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"annotation-highlight.pdf",
"[data-annotation-id='19R']"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -62,11 +62,11 @@ describe("Annotation highlight", () => {
describe("Check that widget annotations are in front of highlight ones", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1883609.pdf", "[data-annotation-id='23R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -87,11 +87,11 @@ describe("Checkbox annotation", () => {
describe("issue12706.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue12706.pdf", "[data-annotation-id='63R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -123,11 +123,11 @@ describe("Checkbox annotation", () => {
describe("issue15597.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue15597.pdf", "[data-annotation-id='7R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -148,11 +148,11 @@ describe("Checkbox annotation", () => {
describe("bug1847733.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1847733.pdf", "[data-annotation-id='18R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -178,11 +178,11 @@ describe("Text widget", () => {
describe("issue13271.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue13271.pdf", "[data-annotation-id='24R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -207,11 +207,11 @@ describe("Text widget", () => {
describe("issue16473.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue16473.pdf", "[data-annotation-id='22R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -236,11 +236,11 @@ describe("Annotation and storage", () => {
describe("issue14023.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue14023.pdf", "[data-annotation-id='64R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -337,11 +337,11 @@ describe("ResetForm action", () => {
describe("resetform.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("resetform.pdf", "[data-annotation-id='63R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -462,14 +462,14 @@ describe("ResetForm action", () => {
describe("issue14438.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"issue14438.pdf",
"[data-annotation-id='10R']"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -490,14 +490,14 @@ describe("ResetForm action", () => {
describe("annotation-caret-ink.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"annotation-caret-ink.pdf",
"[data-annotation-id='25R']"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -525,14 +525,14 @@ describe("ResetForm action", () => {
describe("bug1844583.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"bug1844583.pdf",
"[data-annotation-id='8R']"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -553,14 +553,14 @@ describe("ResetForm action", () => {
describe("tagged_stamp.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tagged_stamp.pdf",
"[data-annotation-id='20R']"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -622,14 +622,14 @@ describe("ResetForm action", () => {
describe("issue14438.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"highlights.pdf",
"[data-annotation-id='693R']"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -652,14 +652,14 @@ describe("ResetForm action", () => {
describe("issue14438.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"rotated_ink.pdf",
"[data-annotation-id='18R']"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -63,7 +63,7 @@ describe("autolinker", function () {
describe("bug1019475_2.pdf", function () {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"bug1019475_2.pdf",
".annotationLayer",
@ -75,7 +75,7 @@ describe("autolinker", function () {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -99,7 +99,7 @@ describe("autolinker", function () {
describe("bug1019475_1.pdf", function () {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"bug1019475_1.pdf",
".annotationLayer",
@ -111,7 +111,7 @@ describe("autolinker", function () {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -138,14 +138,14 @@ describe("autolinker", function () {
describe("pr19449.pdf", function () {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("pr19449.pdf", ".annotationLayer", null, null, {
docBaseUrl: "http://example.com",
enableAutoLinking: true,
});
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -172,7 +172,7 @@ describe("autolinker", function () {
describe("PR 19470", function () {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"bug1019475_2.pdf",
".annotationLayer",
@ -184,7 +184,7 @@ describe("autolinker", function () {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -218,7 +218,7 @@ describe("autolinker", function () {
describe("when highlighting search results", function () {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"issue3115r.pdf",
".annotationLayer",
@ -228,7 +228,7 @@ describe("autolinker", function () {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -27,11 +27,11 @@ describe("Caret browsing", () => {
describe("Selection", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".textLayer .endOfContent");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -40,12 +40,12 @@ describe("Copy and paste", () => {
describe("all text", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", "#hiddenCopyElement", 100);
await mockClipboard(pages);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -137,7 +137,7 @@ describe("Copy and paste", () => {
describe("Copy/paste and ligatures", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"copy_paste_ligatures.pdf",
"#hiddenCopyElement",
@ -146,7 +146,7 @@ describe("Copy and paste", () => {
await mockClipboard(pages);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -28,11 +28,11 @@ describe("find bar", () => {
describe("highlight all", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("find_all.pdf", ".textLayer", 100);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -89,11 +89,11 @@ describe("find bar", () => {
describe("highlight all (XFA)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("xfa_imm5257e.pdf", ".xfaLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -130,11 +130,11 @@ describe("find bar", () => {
describe("issue19207.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue19207.pdf", ".textLayer", 200);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -431,11 +431,11 @@ describe("FreeText Editor", () => {
describe("FreeText (multiselection)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("aboutstacks.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -588,11 +588,11 @@ describe("FreeText Editor", () => {
describe("FreeText (bugs)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -726,7 +726,7 @@ describe("FreeText Editor", () => {
describe("issue 15789", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue15789.pdf", ".annotationEditorLayer");
pages = await Promise.all(
pages.map(async ([browserName, page]) => {
@ -736,7 +736,7 @@ describe("FreeText Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -817,11 +817,11 @@ describe("FreeText Editor", () => {
describe("FreeText (move existing)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("freetexts.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -852,11 +852,11 @@ describe("FreeText Editor", () => {
describe("FreeText (update existing)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("freetexts.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -949,11 +949,11 @@ describe("FreeText Editor", () => {
describe("FreeText (update existing and popups)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("freetexts.pdf", "[data-annotation-id='32R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1004,11 +1004,11 @@ describe("FreeText Editor", () => {
describe("FreeText (update existing but not empty ones)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue14438.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1027,11 +1027,11 @@ describe("FreeText Editor", () => {
describe("FreeText (delete existing)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("freetexts.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1088,11 +1088,11 @@ describe("FreeText Editor", () => {
describe("FreeText (copy/paste existing)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("freetexts.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1116,11 +1116,11 @@ describe("FreeText Editor", () => {
describe("FreeText (edit existing in double clicking on it)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("freetexts.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1151,14 +1151,14 @@ describe("FreeText Editor", () => {
describe("FreeText with popup", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"annotation-freetext.pdf",
".annotationEditorLayer"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1233,11 +1233,11 @@ describe("FreeText Editor", () => {
describe("FreeText rotation", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1333,11 +1333,11 @@ describe("FreeText Editor", () => {
describe("FreeText (remove)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1397,11 +1397,11 @@ describe("FreeText Editor", () => {
describe("FreeText (open existing)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue16633.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1522,7 +1522,7 @@ describe("FreeText Editor", () => {
describe("FreeText (open existing and rotated)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"rotated_freetexts.pdf",
".annotationEditorLayer",
@ -1530,7 +1530,7 @@ describe("FreeText Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1690,11 +1690,11 @@ describe("FreeText Editor", () => {
describe("Keyboard shortcuts when the editor layer isn't focused", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1897,7 +1897,7 @@ describe("FreeText Editor", () => {
describe("Focus must go on the current page", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -1913,7 +1913,7 @@ describe("FreeText Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1962,11 +1962,11 @@ describe("FreeText Editor", () => {
describe("Freetext must stay focused after having been moved", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2037,11 +2037,11 @@ describe("FreeText Editor", () => {
describe("Move several FreeTexts", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2089,7 +2089,7 @@ describe("FreeText Editor", () => {
describe("Don't unselect all when scrolling", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -2104,7 +2104,7 @@ describe("FreeText Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2152,11 +2152,11 @@ describe("FreeText Editor", () => {
describe("FreeText on several pages", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2221,11 +2221,11 @@ describe("FreeText Editor", () => {
describe("Deleted FreeText", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2280,11 +2280,11 @@ describe("FreeText Editor", () => {
describe("FreeText accessibility", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1823296.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2327,11 +2327,11 @@ describe("FreeText Editor", () => {
describe("Bug 1854818: mouse events in a selected FreeText editor", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2474,11 +2474,11 @@ describe("FreeText Editor", () => {
describe("Avoid to steal keyboard events", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2528,11 +2528,11 @@ describe("FreeText Editor", () => {
describe("Delete a freetext in using the delete button", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2571,11 +2571,11 @@ describe("FreeText Editor", () => {
describe("Delete two freetexts in using the delete button and the keyboard", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2625,11 +2625,11 @@ describe("FreeText Editor", () => {
describe("Consecutive white spaces in Freetext without appearance", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1871353.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2656,11 +2656,11 @@ describe("FreeText Editor", () => {
describe("Consecutive white spaces in Freetext with appearance", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1871353.1.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2687,11 +2687,11 @@ describe("FreeText Editor", () => {
describe("Freetext with several lines", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2721,11 +2721,11 @@ describe("FreeText Editor", () => {
describe("Freetext UI when undoing/redoing", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2788,11 +2788,11 @@ describe("FreeText Editor", () => {
describe("Annotation editor layer visibility", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2822,11 +2822,11 @@ describe("FreeText Editor", () => {
describe("Delete a freetext and undo it on another page", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2872,11 +2872,11 @@ describe("FreeText Editor", () => {
describe("Delete a freetext, scroll and undo it", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2917,11 +2917,11 @@ describe("FreeText Editor", () => {
describe("Paste some html", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -3040,14 +3040,14 @@ describe("FreeText Editor", () => {
describe("Update a freetext and scroll", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey_freetext.pdf",
".annotationEditorLayer"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -3170,11 +3170,11 @@ describe("FreeText Editor", () => {
describe("Freetext and shift+enter", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -55,11 +55,11 @@ describe("Highlight Editor", () => {
describe("Editor must be removed without exception", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -101,11 +101,11 @@ describe("Highlight Editor", () => {
describe("Editor must keep selected", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -145,7 +145,7 @@ describe("Highlight Editor", () => {
describe("The default color must have the correct value", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -155,7 +155,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -190,7 +190,7 @@ describe("Highlight Editor", () => {
describe("Invisible editor must change its color", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -200,7 +200,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -278,7 +278,7 @@ describe("Highlight Editor", () => {
describe("Highlight data serialization", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -288,7 +288,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -335,7 +335,7 @@ describe("Highlight Editor", () => {
describe("Color picker and keyboard", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -348,7 +348,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -449,7 +449,7 @@ describe("Highlight Editor", () => {
describe("Text highlights aren't draggable", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -459,7 +459,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -502,11 +502,11 @@ describe("Highlight Editor", () => {
describe("Color picker and click outside", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -543,11 +543,11 @@ describe("Highlight Editor", () => {
describe("Color picker can annoy the user when selecting some text", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -580,7 +580,7 @@ describe("Highlight Editor", () => {
describe("Free highlight thickness can be changed", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"empty.pdf",
".annotationEditorLayer",
@ -590,7 +590,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -660,11 +660,11 @@ describe("Highlight Editor", () => {
describe("Highlight with the keyboard", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -723,7 +723,7 @@ describe("Highlight Editor", () => {
describe("Free highlight is drawn at the right place after having been rotated (bug 1879108)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"empty.pdf",
".annotationEditorLayer",
@ -733,7 +733,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -807,7 +807,7 @@ describe("Highlight Editor", () => {
describe("Highlight links", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"bug1868759.pdf",
".annotationEditorLayer",
@ -817,7 +817,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -852,7 +852,7 @@ describe("Highlight Editor", () => {
describe("Highlight forms", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"issue12233.pdf",
".annotationEditorLayer",
@ -862,7 +862,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -902,7 +902,7 @@ describe("Highlight Editor", () => {
describe("Send a message when some text is selected", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
`.page[data-page-number = "1"] .endOfContent`,
@ -919,7 +919,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -982,7 +982,7 @@ describe("Highlight Editor", () => {
describe("Highlight and caret browsing", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -1002,16 +1002,6 @@ describe("Highlight Editor", () => {
});
afterEach(async () => {
for (const [, page] of pages) {
await page.evaluate(() => {
window.uiManager.reset();
});
// Disable editing mode.
await switchToHighlight(page, /* disable */ true);
}
});
afterAll(async () => {
await closePages(pages);
});
@ -1154,11 +1144,11 @@ describe("Highlight Editor", () => {
describe("Editor must be removed in using the space key on the delete button", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1189,11 +1179,11 @@ describe("Highlight Editor", () => {
describe("Thickness must be enabled when there's no selected highlights", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1244,11 +1234,11 @@ describe("Highlight Editor", () => {
describe("Quadpoints must be correct", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1280,11 +1270,11 @@ describe("Highlight Editor", () => {
describe("Quadpoints must be correct when they're in a translated page", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue18360.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1316,11 +1306,11 @@ describe("Highlight Editor", () => {
describe("Editor must be unselected when the color picker is Escaped", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1348,11 +1338,11 @@ describe("Highlight Editor", () => {
describe("Highlight editor mustn't be moved when close to the page limits", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1386,11 +1376,11 @@ describe("Highlight Editor", () => {
describe("Show/hide all the highlights", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1455,7 +1445,7 @@ describe("Highlight Editor", () => {
describe("Highlight from floating highlight button", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -1465,7 +1455,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1507,11 +1497,11 @@ describe("Highlight Editor", () => {
describe("Text layer must have the focus before highlights", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1550,11 +1540,11 @@ describe("Highlight Editor", () => {
describe("Undo a highlight", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1587,7 +1577,7 @@ describe("Highlight Editor", () => {
describe("Delete a highlight and undo it an other page", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -1600,7 +1590,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1649,7 +1639,7 @@ describe("Highlight Editor", () => {
describe("Delete a highlight, scroll and undo it", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -1662,7 +1652,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1706,7 +1696,7 @@ describe("Highlight Editor", () => {
describe("Use a toolbar overlapping an other highlight", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
@ -1719,7 +1709,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1783,11 +1773,11 @@ describe("Highlight Editor", () => {
describe("Draw a free highlight with the pointer hovering an existing highlight", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1849,11 +1839,11 @@ describe("Highlight Editor", () => {
describe("Select text with the pointer hovering an existing highlight", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1919,7 +1909,7 @@ describe("Highlight Editor", () => {
describe("Highlight with the floating button in a pdf containing a FreeText", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"file_pdfjs_test.pdf",
".annotationEditorLayer",
@ -1929,7 +1919,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1961,7 +1951,7 @@ describe("Highlight Editor", () => {
describe("Highlight (edit existing in double clicking on it)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"highlights.pdf",
".annotationEditorLayer",
@ -1974,7 +1964,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2008,14 +1998,14 @@ describe("Highlight Editor", () => {
describe("Highlight (delete an existing annotation)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"highlight_popup.pdf",
".annotationEditorLayer"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2052,7 +2042,7 @@ describe("Highlight Editor", () => {
describe("Free Highlight (edit existing in double clicking on it)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"highlights.pdf",
".annotationEditorLayer",
@ -2065,7 +2055,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2101,14 +2091,14 @@ describe("Highlight Editor", () => {
describe("Highlight editor mustn't throw when disabled", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"annotation-highlight.pdf",
".annotationEditorLayer"
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2134,7 +2124,7 @@ describe("Highlight Editor", () => {
describe("Free Highlight with an image in the struct tree", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"bug1708040.pdf",
".annotationEditorLayer",
@ -2144,7 +2134,7 @@ describe("Highlight Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2623,11 +2613,11 @@ describe("Highlight Editor", () => {
describe("Highlight mustn't trigger a scroll when edited", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue18911.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2678,11 +2668,11 @@ describe("Highlight Editor", () => {
describe("Highlight must be rotated when existing in the pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue19424.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -23,7 +23,7 @@ async function runTests(results) {
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
jasmine.loadConfig({
random: false,
random: true,
spec_dir: "integration",
spec_files: [
"accessibility_spec.mjs",

View File

@ -1197,13 +1197,6 @@ describe("Interaction", () => {
await page.waitForFunction(
`${getQuerySelector("27R")}.value === "HEAO "`
);
// The typing actions in the first textbox caused sandbox events to be
// queued. We don't close the document between tests, so we have to
// flush them here, by clicking the second textbox, so they don't leak
// through to the following test.
await page.click(getSelector("28R"));
await waitForSandboxTrip(page);
})
);
});

View File

@ -16,7 +16,6 @@
import {
applyFunctionToEditor,
awaitPromise,
cleanupEditing,
clearEditors,
clearInput,
closePages,
@ -31,7 +30,6 @@ import {
getRect,
getSerialized,
isCanvasMonochrome,
isVisible,
kbBigMoveDown,
kbBigMoveRight,
kbUndo,
@ -101,7 +99,7 @@ describe("Stamp Editor", () => {
describe("Basic operations", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer", null, {
eventBusSetup: eventBus => {
eventBus.on("annotationeditoruimanager", ({ uiManager }) => {
@ -112,10 +110,6 @@ describe("Stamp Editor", () => {
});
afterEach(async () => {
await cleanupEditing(pages, switchToStamp);
});
afterAll(async () => {
await closePages(pages);
});
@ -203,7 +197,7 @@ describe("Stamp Editor", () => {
describe("Resize", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer", 50, {
eventBusSetup: eventBus => {
eventBus.on("annotationeditoruimanager", ({ uiManager }) => {
@ -213,12 +207,8 @@ describe("Stamp Editor", () => {
});
});
afterAll(async () => {
await closePages(pages);
});
afterEach(async () => {
await cleanupEditing(pages, switchToStamp);
await closePages(pages);
});
it("must check that an added image stay within the page", async () => {
@ -325,11 +315,11 @@ describe("Stamp Editor", () => {
describe("Alt text dialog", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer", 50);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -500,11 +490,11 @@ describe("Stamp Editor", () => {
describe("Resize an image with the keyboard", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer", 50);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -631,12 +621,12 @@ describe("Stamp Editor", () => {
describe("Copy/paste from a tab to an other", () => {
let pages1, pages2;
beforeAll(async () => {
beforeEach(async () => {
pages1 = await loadAndWait("empty.pdf", ".annotationEditorLayer");
pages2 = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages1);
await closePages(pages2);
});
@ -665,11 +655,11 @@ describe("Stamp Editor", () => {
describe("Undo a stamp", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -697,11 +687,11 @@ describe("Stamp Editor", () => {
describe("Delete a stamp and undo it on another page", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -742,11 +732,11 @@ describe("Stamp Editor", () => {
describe("Delete a stamp, scroll and undo it", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -782,11 +772,11 @@ describe("Stamp Editor", () => {
describe("Resize a stamp", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -832,7 +822,7 @@ describe("Stamp Editor", () => {
describe("Add a stamp in odd spread mode", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"empty.pdf",
".annotationEditorLayer",
@ -844,7 +834,7 @@ describe("Stamp Editor", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -873,11 +863,11 @@ describe("Stamp Editor", () => {
describe("Copy and paste a stamp with an alt text", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -918,7 +908,7 @@ describe("Stamp Editor", () => {
describe("New alt-text flow", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"empty.pdf",
".annotationEditorLayer",
@ -942,23 +932,6 @@ describe("Stamp Editor", () => {
});
afterEach(async () => {
for (const [, page] of pages) {
if (await isVisible(page, "#newAltTextDialog")) {
await page.keyboard.press("Escape");
await page.waitForSelector("#newAltTextDisclaimer", {
visible: false,
});
}
await page.evaluate(() => {
window.uiManager.reset();
window.telemetry = [];
});
// Disable editing mode.
await switchToStamp(page, /* disable */ true);
}
});
afterAll(async () => {
await closePages(pages);
});
@ -1296,7 +1269,7 @@ describe("Stamp Editor", () => {
describe("New alt-text flow (bug 1920515)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"empty.pdf",
".annotationEditorLayer",
@ -1318,22 +1291,6 @@ describe("Stamp Editor", () => {
});
afterEach(async () => {
for (const [, page] of pages) {
if (await isVisible(page, "#newAltTextDialog")) {
await page.keyboard.press("Escape");
await page.waitForSelector("#newAltTextDisclaimer", {
visible: false,
});
}
await page.evaluate(() => {
window.uiManager.reset();
});
// Disable editing mode.
await switchToStamp(page, /* disable */ true);
}
});
afterAll(async () => {
await closePages(pages);
});
@ -1364,11 +1321,11 @@ describe("Stamp Editor", () => {
describe("No auto-resize", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer", 67);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1410,11 +1367,11 @@ describe("Stamp Editor", () => {
describe("A stamp musn't be on top of the secondary toolbar", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer", 600);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1431,15 +1388,10 @@ describe("Stamp Editor", () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const debug = false;
await page.click("#secondaryToolbarToggleButton");
await page.waitForSelector("#secondaryToolbar", { visible: true });
const secondary = await page.$("#secondaryToolbar");
const png = await secondary.screenshot({
type: "png",
path: debug ? `foo.png` : "",
});
const png = await secondary.screenshot({ type: "png" });
const secondaryImage = PNG.sync.read(Buffer.from(png));
const buffer = new Uint32Array(secondaryImage.data.buffer);
expect(buffer.every(x => x === 0xff0000ff))
@ -1453,11 +1405,11 @@ describe("Stamp Editor", () => {
describe("Stamp (move existing)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("stamps.pdf", getAnnotationSelector("25R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1491,11 +1443,11 @@ describe("Stamp Editor", () => {
describe("Stamp (change alt-text)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("stamps.pdf", getAnnotationSelector("58R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1551,11 +1503,11 @@ describe("Stamp Editor", () => {
describe("Stamp (delete existing and undo)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("stamps.pdf", getAnnotationSelector("37R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1599,11 +1551,11 @@ describe("Stamp Editor", () => {
describe("Drag a stamp annotation and click on a touchscreen", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1725,11 +1677,11 @@ describe("Stamp Editor", () => {
describe("Switch to edit mode a pdf with an existing stamp annotation on an invisible and rendered page", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue19239.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1755,11 +1707,11 @@ describe("Stamp Editor", () => {
describe("Switch to edit mode a pdf with an existing stamp annotation on an invisible and unrendered page", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue19239.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1794,11 +1746,11 @@ describe("Stamp Editor", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue19239.pdf", annotationSelector);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1825,11 +1777,11 @@ describe("Stamp Editor", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("red_stamp.pdf", annotationSelector, 20);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -137,13 +137,6 @@ function closePages(pages) {
return Promise.all(pages.map(([_, page]) => closeSinglePage(page)));
}
function isVisible(page, selector) {
return page.evaluate(
sel => document.querySelector(sel)?.checkVisibility(),
selector
);
}
async function closeSinglePage(page) {
// Avoid to keep something from a previous test.
await page.evaluate(async () => {
@ -861,16 +854,6 @@ function isCanvasMonochrome(page, pageNumber, rectangle, color) {
);
}
async function cleanupEditing(pages, switcher) {
for (const [, page] of pages) {
await page.evaluate(() => {
window.uiManager.reset();
});
// Disable editing mode.
await switcher(page, /* disable */ true);
}
}
async function getXY(page, selector) {
const rect = await getRect(page, selector);
return `${rect.x}::${rect.y}`;
@ -902,7 +885,6 @@ async function moveEditor(page, selector, n, pressKey) {
export {
applyFunctionToEditor,
awaitPromise,
cleanupEditing,
clearEditors,
clearInput,
closePages,
@ -927,7 +909,6 @@ export {
getXY,
hover,
isCanvasMonochrome,
isVisible,
kbBigMoveDown,
kbBigMoveLeft,
kbBigMoveRight,

View File

@ -19,11 +19,11 @@ describe("Text field", () => {
describe("Empty text field", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("file_pdfjs_form.pdf", getSelector("7R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -59,7 +59,7 @@ describe("Text layer", () => {
};
}
beforeAll(() => {
beforeEach(() => {
jasmine.addAsyncMatchers({
// Check that a page has a selection containing the given text, with
// some tolerance for extra characters before/after.
@ -111,13 +111,13 @@ describe("Text layer", () => {
describe("doesn't jump when hovering on an empty area", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
`.page[data-page-number = "1"] .endOfContent`
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -220,13 +220,13 @@ describe("Text layer", () => {
describe("doesn't jump when hovering on an empty area, with .markedContent", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"chrome-text-selection-markedContent.pdf",
`.page[data-page-number = "1"] .endOfContent`
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -318,22 +318,15 @@ describe("Text layer", () => {
describe("when selecting over a link", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"annotation-link-text-popup.pdf",
`.page[data-page-number = "1"] .endOfContent`
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
afterEach(() =>
Promise.all(
pages.map(([_, page]) =>
page.evaluate(() => window.getSelection().removeAllRanges())
)
)
);
it("allows selecting within the link", async () => {
await Promise.all(
@ -451,7 +444,7 @@ describe("Text layer", () => {
let browser;
let page;
beforeAll(async () => {
beforeEach(async () => {
// Chrome does not support simulating caret-based selection, so this
// test only runs in Firefox.
browser = await startBrowser({
@ -472,7 +465,7 @@ describe("Text layer", () => {
{ timeout: 0 }
);
});
afterAll(async () => {
afterEach(async () => {
await closeSinglePage(page);
await browser.close();
});
@ -542,7 +535,7 @@ describe("Text layer", () => {
let browser;
let page;
beforeAll(async () => {
beforeEach(async () => {
// Only testing in Firefox because, while Chrome has a setting similar to
// font.minimum-size.x-western, it is not exposed through its API.
browser = await startBrowser({
@ -561,7 +554,7 @@ describe("Text layer", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closeSinglePage(page);
await browser.close();
});

View File

@ -28,7 +28,7 @@ describe("PDF viewer", () => {
describe("Zoom origin", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".textLayer .endOfContent",
@ -38,7 +38,7 @@ describe("PDF viewer", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -107,11 +107,11 @@ describe("PDF viewer", () => {
describe("Zoom with the mouse wheel", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".textLayer .endOfContent", 1000);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -141,11 +141,11 @@ describe("PDF viewer", () => {
describe("Zoom commands", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".textLayer .endOfContent");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -191,7 +191,7 @@ describe("PDF viewer", () => {
describe("forced (maxCanvasPixels: 0)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".textLayer .endOfContent",
@ -201,7 +201,7 @@ describe("PDF viewer", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -257,7 +257,7 @@ describe("PDF viewer", () => {
const MAX_CANVAS_PIXELS = new Map();
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".textLayer .endOfContent",
@ -271,9 +271,7 @@ describe("PDF viewer", () => {
return { maxCanvasPixels };
}
);
});
beforeEach(async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const handle = await waitForPageRendered(page);
@ -294,7 +292,7 @@ describe("PDF viewer", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -387,7 +385,7 @@ describe("PDF viewer", () => {
describe("Canvas fits the page", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"issue18694.pdf",
".textLayer .endOfContent",
@ -395,14 +393,20 @@ describe("PDF viewer", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
it("must check that canvas perfectly fits the page whatever the zoom level is", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const debug = false;
if (browserName === "chrome") {
// Skip the test for Chrome as `scrollIntoView` below hangs since
// Puppeteer 24.5.0 and higher.
// See https://github.com/mozilla/pdf.js/issues/19811.
// TODO: Remove this check once the issue is fixed.
return;
}
// The pdf has a single page with a red background.
// We set the viewer background to red, because when screenshoting
@ -428,10 +432,7 @@ describe("PDF viewer", () => {
await scrollIntoView(page, `.page[data-page-number="1"]`);
const element = await page.$(`.page[data-page-number="1"]`);
const png = await element.screenshot({
type: "png",
path: debug ? `foo${i}.png` : "",
});
const png = await element.screenshot({ type: "png" });
const pageImage = PNG.sync.read(Buffer.from(png));
let buffer = new Uint32Array(pageImage.data.buffer);
@ -461,7 +462,7 @@ describe("PDF viewer", () => {
function setupPages(zoom, devicePixelRatio, setups = {}) {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"colors.pdf",
null,
@ -480,7 +481,7 @@ describe("PDF viewer", () => {
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1121,11 +1122,11 @@ describe("PDF viewer", () => {
);
}
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue18694.pdf", ".textLayer .endOfContent");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});

View File

@ -22,6 +22,18 @@ import { Jbig2Error, Jbig2Image } from "../../src/core/jbig2.js";
import { JpegError, JpegImage } from "../../src/core/jpg.js";
import { JpxError, JpxImage } from "../../src/core/jpx.js";
const expectedAPI = Object.freeze({
getVerbosityLevel,
Jbig2Error,
Jbig2Image,
JpegError,
JpegImage,
JpxError,
JpxImage,
setVerbosityLevel,
VerbosityLevel,
});
describe("pdfimage_api", function () {
it("checks that the *official* PDF.js-image decoders API exposes the expected functionality", async function () {
// eslint-disable-next-line no-unsanitized/method
@ -33,16 +45,10 @@ describe("pdfimage_api", function () {
// The imported Object contains an (automatically) inserted Symbol,
// hence we copy the data to allow using a simple comparison below.
expect({ ...pdfimageAPI }).toEqual({
getVerbosityLevel,
Jbig2Error,
Jbig2Image,
JpegError,
JpegImage,
JpxError,
JpxImage,
setVerbosityLevel,
VerbosityLevel,
});
expect({ ...pdfimageAPI }).toEqual(expectedAPI);
expect(Object.keys(globalThis.pdfjsImageDecoders).sort()).toEqual(
Object.keys(expectedAPI).sort()
);
});
});

View File

@ -13,9 +13,20 @@
* limitations under the License.
*/
import { PDFWorker } from "../../src/display/api.js";
import { WorkerMessageHandler } from "../../src/core/worker.js";
const expectedAPI = Object.freeze({
WorkerMessageHandler,
});
describe("pdfworker_api", function () {
afterEach(function () {
// Avoid interfering with other unit-tests, since `globalThis.pdfjsWorker`
// being defined will impact loading and usage of the worker.
PDFWorker._resetGlobalState();
});
it("checks that the *official* PDF.js-worker API exposes the expected functionality", async function () {
// eslint-disable-next-line no-unsanitized/method
const pdfworkerAPI = await import(
@ -26,8 +37,10 @@ describe("pdfworker_api", function () {
// The imported Object contains an (automatically) inserted Symbol,
// hence we copy the data to allow using a simple comparison below.
expect({ ...pdfworkerAPI }).toEqual({
WorkerMessageHandler,
});
expect({ ...pdfworkerAPI }).toEqual(expectedAPI);
expect(Object.keys(globalThis.pdfjsWorker).sort()).toEqual(
Object.keys(expectedAPI).sort()
);
});
});

View File

@ -135,6 +135,10 @@ describe("pdfjs_api", function () {
// The imported Object contains an (automatically) inserted Symbol,
// hence we copy the data to allow using a simple comparison below.
expect({ ...pdfjsAPI }).toEqual(expectedAPI);
expect(Object.keys(globalThis.pdfjsLib).sort()).toEqual(
Object.keys(expectedAPI).sort()
);
});
});

View File

@ -39,35 +39,41 @@ import { StructTreeLayerBuilder } from "../../web/struct_tree_layer_builder.js";
import { TextLayerBuilder } from "../../web/text_layer_builder.js";
import { XfaLayerBuilder } from "../../web/xfa_layer_builder.js";
const expectedAPI = Object.freeze({
AnnotationLayerBuilder,
DownloadManager,
EventBus,
FindState,
GenericL10n,
LinkTarget,
parseQueryString,
PDFFindController,
PDFHistory,
PDFLinkService,
PDFPageView,
PDFScriptingManager,
PDFSinglePageViewer,
PDFViewer,
ProgressBar,
RenderingStates,
ScrollMode,
SimpleLinkService,
SpreadMode,
StructTreeLayerBuilder,
TextLayerBuilder,
XfaLayerBuilder,
});
describe("pdfviewer_api", function () {
it("checks that the *official* PDF.js-viewer API exposes the expected functionality", async function () {
const pdfviewerAPI = await import("../../web/pdf_viewer.component.js");
// The imported Object contains an (automatically) inserted Symbol,
// hence we copy the data to allow using a simple comparison below.
expect({ ...pdfviewerAPI }).toEqual({
AnnotationLayerBuilder,
DownloadManager,
EventBus,
FindState,
GenericL10n,
LinkTarget,
parseQueryString,
PDFFindController,
PDFHistory,
PDFLinkService,
PDFPageView,
PDFScriptingManager,
PDFSinglePageViewer,
PDFViewer,
ProgressBar,
RenderingStates,
ScrollMode,
SimpleLinkService,
SpreadMode,
StructTreeLayerBuilder,
TextLayerBuilder,
XfaLayerBuilder,
});
expect({ ...pdfviewerAPI }).toEqual(expectedAPI);
expect(Object.keys(globalThis.pdfjsViewer).sort()).toEqual(
Object.keys(expectedAPI).sort()
);
});
});

View File

@ -46,6 +46,31 @@ const pdfjsVersion =
const pdfjsBuild =
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0;
globalThis.pdfjsViewer = {
AnnotationLayerBuilder,
DownloadManager,
EventBus,
FindState,
GenericL10n,
LinkTarget,
parseQueryString,
PDFFindController,
PDFHistory,
PDFLinkService,
PDFPageView,
PDFScriptingManager,
PDFSinglePageViewer,
PDFViewer,
ProgressBar,
RenderingStates,
ScrollMode,
SimpleLinkService,
SpreadMode,
StructTreeLayerBuilder,
TextLayerBuilder,
XfaLayerBuilder,
};
export {
AnnotationLayerBuilder,
DownloadManager,