Don't show the print dialog when printing in some integration tests

This commit is contained in:
Calixte Denizet 2024-08-20 22:24:08 +01:00
parent e0fc1a341a
commit b0c239a200
2 changed files with 48 additions and 41 deletions

View file

@ -60,11 +60,15 @@ function loadAndWait(filename, selector, zoom, setups, options) {
// and EventBus, so we can inject some code to do whatever we want
// soon enough especially before the first event in the eventBus is
// dispatched.
const { prePageSetup, appSetup, eventBusSetup } = setups;
const { prePageSetup, appSetup, earlySetup, eventBusSetup } = setups;
await prePageSetup?.(page);
if (appSetup || eventBusSetup) {
if (earlySetup || appSetup || eventBusSetup) {
await page.evaluateOnNewDocument(
(aSetup, eSetup) => {
(eaSetup, aSetup, evSetup) => {
if (eaSetup) {
// eslint-disable-next-line no-eval
eval(`(${eaSetup})`)();
}
let app;
let eventBus;
Object.defineProperty(window, "PDFViewerApplication", {
@ -83,13 +87,16 @@ function loadAndWait(filename, selector, zoom, setups, options) {
},
set(newV) {
eventBus = newV;
// eslint-disable-next-line no-eval
eval(`(${eSetup})`)(eventBus);
if (evSetup) {
// eslint-disable-next-line no-eval
eval(`(${evSetup})`)(eventBus);
}
},
});
},
});
},
earlySetup?.toString(),
appSetup?.toString(),
eventBusSetup?.toString()
);