mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Don't close the secondaryToolbar
when clicking inside it (PR 18385 follow-up)
When the DOM structure of the viewer was updated in PR 18385 it caused the `secondaryToolbar` to accidentally start closing when clicking inside of it, since the `secondaryToolbar` now reside *under* the `toolbar` in the DOM. **Steps to reproduce:** - Open the viewer. - Open the `secondaryToolbar`. - Try to change document rotation at least *twice*. **Expected behaviour:** The document rotation can be changed an arbitrary number of times. **Actual results:** The `secondaryToolbar` closes after changing rotation just once.
This commit is contained in:
parent
391e84c34b
commit
221eba29b9
2 changed files with 70 additions and 5 deletions
|
@ -1096,4 +1096,68 @@ 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));
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue