mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-02 20:37:21 +02:00
Merge pull request #20767 from calixteman/followup_20742
Add an integration test for the issue fixed in #20742
This commit is contained in:
commit
98d0332a9f
@ -22,6 +22,7 @@ import {
|
|||||||
loadAndWait,
|
loadAndWait,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
showViewsManager,
|
showViewsManager,
|
||||||
|
waitAndClick,
|
||||||
waitForPageChanging,
|
waitForPageChanging,
|
||||||
waitForPageRendered,
|
waitForPageRendered,
|
||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
@ -1528,6 +1529,77 @@ describe("PDF viewer", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Find current outline item scrolls into view (PR 20742)", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
pages = await loadAndWait(
|
||||||
|
"freeculture.pdf",
|
||||||
|
".textLayer .endOfContent",
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
{ width: 1280, height: 600 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must scroll the selected outline item into the visible sidebar area", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
// Open the sidebar.
|
||||||
|
await showViewsManager(page);
|
||||||
|
|
||||||
|
// Switch to outline view.
|
||||||
|
await page.click("#viewsManagerSelectorButton");
|
||||||
|
await waitAndClick(page, "#outlinesViewMenu");
|
||||||
|
|
||||||
|
// Wait for the outline tree to render.
|
||||||
|
await page.waitForSelector("#outlinesView .treeItem", {
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Navigate to page 310, which maps to a nested outline item inside
|
||||||
|
// a collapsed parent; _scrollToCurrentTreeItem will expand the parent
|
||||||
|
// and scroll the item into view.
|
||||||
|
await page.evaluate(() => {
|
||||||
|
window.PDFViewerApplication.page = 310;
|
||||||
|
});
|
||||||
|
await page.waitForFunction(
|
||||||
|
() => window.PDFViewerApplication.page === 310
|
||||||
|
);
|
||||||
|
await page.waitForSelector(
|
||||||
|
".page[data-page-number='310'] .textLayer .endOfContent"
|
||||||
|
);
|
||||||
|
|
||||||
|
await waitAndClick(
|
||||||
|
page,
|
||||||
|
"#viewsManagerCurrentOutlineButton:not(:disabled)"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Wait for an outline item to receive the "selected" class.
|
||||||
|
const item = await page.waitForSelector(
|
||||||
|
"#outlinesView .treeItemToggler:not(.treeItemsHidden) + a + .treeItems > .treeItem.selected",
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const isVisible = await item.isIntersectingViewport();
|
||||||
|
expect(isVisible).withContext(`In ${browserName}`).toBeTrue();
|
||||||
|
const outlineItemText = await item.evaluate(el =>
|
||||||
|
el.textContent.trim()
|
||||||
|
);
|
||||||
|
expect(outlineItemText)
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toBe("Fire Lots of Lawyers");
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("Scroll into view", () => {
|
describe("Scroll into view", () => {
|
||||||
let pages;
|
let pages;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user