Compare commits

..

No commits in common. "2f7d163dfdf40225479d1cc8f6d8ebd9e5273ca6" and "c071f448838b35ef991312fca34f27768d5b3ae1" have entirely different histories.

28 changed files with 449 additions and 477 deletions

View File

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

8
package-lock.json generated
View File

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

View File

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

View File

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

View File

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

View File

@ -93,59 +93,6 @@ 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 { export {
AbortException, AbortException,
AnnotationEditorLayer, AnnotationEditorLayer,

View File

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

4
src/pdf.worker.js vendored
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -137,6 +137,13 @@ function closePages(pages) {
return Promise.all(pages.map(([_, page]) => closeSinglePage(page))); 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) { async function closeSinglePage(page) {
// Avoid to keep something from a previous test. // Avoid to keep something from a previous test.
await page.evaluate(async () => { await page.evaluate(async () => {
@ -854,6 +861,16 @@ 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) { async function getXY(page, selector) {
const rect = await getRect(page, selector); const rect = await getRect(page, selector);
return `${rect.x}::${rect.y}`; return `${rect.x}::${rect.y}`;
@ -885,6 +902,7 @@ async function moveEditor(page, selector, n, pressKey) {
export { export {
applyFunctionToEditor, applyFunctionToEditor,
awaitPromise, awaitPromise,
cleanupEditing,
clearEditors, clearEditors,
clearInput, clearInput,
closePages, closePages,
@ -909,6 +927,7 @@ export {
getXY, getXY,
hover, hover,
isCanvasMonochrome, isCanvasMonochrome,
isVisible,
kbBigMoveDown, kbBigMoveDown,
kbBigMoveLeft, kbBigMoveLeft,
kbBigMoveRight, kbBigMoveRight,

View File

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

View File

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

View File

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

View File

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

View File

@ -13,20 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
import { PDFWorker } from "../../src/display/api.js";
import { WorkerMessageHandler } from "../../src/core/worker.js"; import { WorkerMessageHandler } from "../../src/core/worker.js";
const expectedAPI = Object.freeze({
WorkerMessageHandler,
});
describe("pdfworker_api", function () { 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 () { it("checks that the *official* PDF.js-worker API exposes the expected functionality", async function () {
// eslint-disable-next-line no-unsanitized/method // eslint-disable-next-line no-unsanitized/method
const pdfworkerAPI = await import( const pdfworkerAPI = await import(
@ -37,10 +26,8 @@ describe("pdfworker_api", function () {
// The imported Object contains an (automatically) inserted Symbol, // The imported Object contains an (automatically) inserted Symbol,
// hence we copy the data to allow using a simple comparison below. // hence we copy the data to allow using a simple comparison below.
expect({ ...pdfworkerAPI }).toEqual(expectedAPI); expect({ ...pdfworkerAPI }).toEqual({
WorkerMessageHandler,
expect(Object.keys(globalThis.pdfjsWorker).sort()).toEqual( });
Object.keys(expectedAPI).sort()
);
}); });
}); });

View File

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

View File

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

View File

@ -46,31 +46,6 @@ const pdfjsVersion =
const pdfjsBuild = const pdfjsBuild =
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0; 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 { export {
AnnotationLayerBuilder, AnnotationLayerBuilder,
DownloadManager, DownloadManager,