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

8
package-lock.json generated
View File

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

View File

@ -53,7 +53,7 @@
"ttest": "^4.0.0",
"typescript": "^5.8.3",
"vinyl": "^3.0.0",
"webpack": "^5.99.5",
"webpack": "^5.98.0",
"webpack-stream": "^7.0.0",
"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({

View File

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

View File

@ -93,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 {
AbortException,
AnnotationEditorLayer,

View File

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

4
src/pdf.worker.js vendored
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ describe("PDF viewer", () => {
describe("Zoom origin", () => {
let pages;
beforeEach(async () => {
beforeAll(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".textLayer .endOfContent",
@ -38,7 +38,7 @@ describe("PDF viewer", () => {
);
});
afterEach(async () => {
afterAll(async () => {
await closePages(pages);
});
@ -107,11 +107,11 @@ describe("PDF viewer", () => {
describe("Zoom with the mouse wheel", () => {
let pages;
beforeEach(async () => {
beforeAll(async () => {
pages = await loadAndWait("empty.pdf", ".textLayer .endOfContent", 1000);
});
afterEach(async () => {
afterAll(async () => {
await closePages(pages);
});
@ -141,11 +141,11 @@ describe("PDF viewer", () => {
describe("Zoom commands", () => {
let pages;
beforeEach(async () => {
beforeAll(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".textLayer .endOfContent");
});
afterEach(async () => {
afterAll(async () => {
await closePages(pages);
});
@ -191,7 +191,7 @@ describe("PDF viewer", () => {
describe("forced (maxCanvasPixels: 0)", () => {
let pages;
beforeEach(async () => {
beforeAll(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".textLayer .endOfContent",
@ -201,7 +201,7 @@ describe("PDF viewer", () => {
);
});
afterEach(async () => {
afterAll(async () => {
await closePages(pages);
});
@ -257,7 +257,7 @@ describe("PDF viewer", () => {
const MAX_CANVAS_PIXELS = new Map();
beforeEach(async () => {
beforeAll(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".textLayer .endOfContent",
@ -271,7 +271,9 @@ describe("PDF viewer", () => {
return { maxCanvasPixels };
}
);
});
beforeEach(async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const handle = await waitForPageRendered(page);
@ -292,7 +294,7 @@ describe("PDF viewer", () => {
);
});
afterEach(async () => {
afterAll(async () => {
await closePages(pages);
});
@ -385,7 +387,7 @@ describe("PDF viewer", () => {
describe("Canvas fits the page", () => {
let pages;
beforeEach(async () => {
beforeAll(async () => {
pages = await loadAndWait(
"issue18694.pdf",
".textLayer .endOfContent",
@ -393,20 +395,14 @@ describe("PDF viewer", () => {
);
});
afterEach(async () => {
afterAll(async () => {
await closePages(pages);
});
it("must check that canvas perfectly fits the page whatever the zoom level is", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
if (browserName === "chrome") {
// Skip the test for Chrome as `scrollIntoView` below hangs since
// Puppeteer 24.5.0 and higher.
// See https://github.com/mozilla/pdf.js/issues/19811.
// TODO: Remove this check once the issue is fixed.
return;
}
const debug = false;
// The pdf has a single page with a red background.
// 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"]`);
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));
let buffer = new Uint32Array(pageImage.data.buffer);
@ -462,7 +461,7 @@ describe("PDF viewer", () => {
function setupPages(zoom, devicePixelRatio, setups = {}) {
let pages;
beforeEach(async () => {
beforeAll(async () => {
pages = await loadAndWait(
"colors.pdf",
null,
@ -481,7 +480,7 @@ describe("PDF viewer", () => {
);
});
afterEach(async () => {
afterAll(async () => {
await closePages(pages);
});
@ -1122,11 +1121,11 @@ describe("PDF viewer", () => {
);
}
beforeEach(async () => {
beforeAll(async () => {
pages = await loadAndWait("issue18694.pdf", ".textLayer .endOfContent");
});
afterEach(async () => {
afterAll(async () => {
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 { JpxError, JpxImage } from "../../src/core/jpx.js";
const expectedAPI = Object.freeze({
getVerbosityLevel,
Jbig2Error,
Jbig2Image,
JpegError,
JpegImage,
JpxError,
JpxImage,
setVerbosityLevel,
VerbosityLevel,
});
describe("pdfimage_api", function () {
it("checks that the *official* PDF.js-image decoders API exposes the expected functionality", async function () {
// eslint-disable-next-line no-unsanitized/method
@ -45,10 +33,16 @@ describe("pdfimage_api", function () {
// The imported Object contains an (automatically) inserted Symbol,
// hence we copy the data to allow using a simple comparison below.
expect({ ...pdfimageAPI }).toEqual(expectedAPI);
expect(Object.keys(globalThis.pdfjsImageDecoders).sort()).toEqual(
Object.keys(expectedAPI).sort()
);
expect({ ...pdfimageAPI }).toEqual({
getVerbosityLevel,
Jbig2Error,
Jbig2Image,
JpegError,
JpegImage,
JpxError,
JpxImage,
setVerbosityLevel,
VerbosityLevel,
});
});
});

View File

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

View File

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

View File

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

View File

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