mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 12:57:20 +02:00
Compare commits
No commits in common. "d74619847de44bf1ff48afc342596c11e4838231" and "391e84c34bfd867e787d89971c821d6877834f19" have entirely different histories.
d74619847d
...
391e84c34b
@ -1096,68 +1096,4 @@ describe("PDF viewer", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("SecondaryToolbar", () => {
|
|
||||||
let pages;
|
|
||||||
|
|
||||||
function normalizeRotation(rotation) {
|
|
||||||
return ((rotation % 360) + 360) % 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
function waitForRotationChanging(page, pagesRotation) {
|
|
||||||
return page.evaluateHandle(
|
|
||||||
rotation => [
|
|
||||||
new Promise(resolve => {
|
|
||||||
const { eventBus } = window.PDFViewerApplication;
|
|
||||||
eventBus.on("rotationchanging", function handler(e) {
|
|
||||||
if (rotation === undefined || e.pagesRotation === rotation) {
|
|
||||||
resolve();
|
|
||||||
eventBus.off("rotationchanging", handler);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
normalizeRotation(pagesRotation)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
pages = await loadAndWait("issue18694.pdf", ".textLayer .endOfContent");
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
await closePages(pages);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("must check that the SecondaryToolbar doesn't close between rotations", async () => {
|
|
||||||
await Promise.all(
|
|
||||||
pages.map(async ([browserName, page]) => {
|
|
||||||
await page.click("#secondaryToolbarToggleButton");
|
|
||||||
await page.waitForSelector("#secondaryToolbar", { hidden: false });
|
|
||||||
|
|
||||||
for (let i = 1; i <= 4; i++) {
|
|
||||||
const secondaryToolbarIsOpen = await page.evaluate(
|
|
||||||
() => window.PDFViewerApplication.secondaryToolbar.isOpen
|
|
||||||
);
|
|
||||||
expect(secondaryToolbarIsOpen)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toBeTrue();
|
|
||||||
|
|
||||||
const rotation = i * 90;
|
|
||||||
const handle = await waitForRotationChanging(page, rotation);
|
|
||||||
|
|
||||||
await page.click("#pageRotateCw");
|
|
||||||
await awaitPromise(handle);
|
|
||||||
|
|
||||||
const pagesRotation = await page.evaluate(
|
|
||||||
() => window.PDFViewerApplication.pdfViewer.pagesRotation
|
|
||||||
);
|
|
||||||
expect(pagesRotation)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toBe(normalizeRotation(rotation));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
11
web/app.js
11
web/app.js
@ -2683,19 +2683,18 @@ function onWheel(evt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeSecondaryToolbar({ target }) {
|
function closeSecondaryToolbar(evt) {
|
||||||
if (!this.secondaryToolbar?.isOpen) {
|
if (!this.secondaryToolbar?.isOpen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { toolbar, secondaryToolbar } = this.appConfig;
|
const appConfig = this.appConfig;
|
||||||
if (
|
if (
|
||||||
this.pdfViewer.containsElement(target) ||
|
this.pdfViewer.containsElement(evt.target) ||
|
||||||
(toolbar?.container.contains(target) &&
|
(appConfig.toolbar?.container.contains(evt.target) &&
|
||||||
!secondaryToolbar?.toolbar.contains(target) &&
|
|
||||||
// TODO: change the `contains` for an equality check when the bug:
|
// TODO: change the `contains` for an equality check when the bug:
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1921984
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1921984
|
||||||
// is fixed.
|
// is fixed.
|
||||||
!secondaryToolbar?.toggleButton.contains(target))
|
!appConfig.secondaryToolbar?.toggleButton.contains(evt.target))
|
||||||
) {
|
) {
|
||||||
this.secondaryToolbar.close();
|
this.secondaryToolbar.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user