Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions test/integration/reorganize_pages_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -486,4 +486,71 @@ describe("Reorganize Pages View", () => {
);
});
});

describe("Drag marker must have the right non-zero dimensions", () => {
let pages;

beforeEach(async () => {
pages = await loadAndWait(
"page_with_number_and_link.pdf",
"#viewsManagerToggleButton",
"1",
null,
{
enableSplitMerge: true,
sidebarViewOnLoad: 2 /* = SidebarView.OUTLINES */,
}
);
});

afterEach(async () => {
await closePages(pages);
});

it("should check if the drag marker width is non-zero", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForSelector("#outlinesView", { visible: true });
await page.waitForSelector("#viewsManagerSelectorButton", {
visible: true,
});
await page.click("#viewsManagerSelectorButton");
await page.waitForSelector("#thumbnailsViewMenu", { visible: true });
await page.click("#thumbnailsViewMenu");

const thumbSelector = "#thumbnailsView .thumbnailImage";
await page.waitForSelector(thumbSelector, { visible: true });
const rect1 = await getRect(page, getThumbnailSelector(1));
const rect2 = await getRect(page, getThumbnailSelector(2));

const handleAddedMarker = await waitForDOMMutation(
page,
mutationList => {
for (const mutation of mutationList) {
if (mutation.type !== "childList") {
continue;
}
for (const node of mutation.addedNodes) {
if (node.classList.contains("dragMarker")) {
const rect = node.getBoundingClientRect();
return rect.width !== 0;
}
}
}
return false;
}
);

await dragAndDrop(
page,
getThumbnailSelector(1),
[[0, rect2.y - rect1.y + rect2.height / 2]],
10
);

await awaitPromise(handleAddedMarker);
})
);
});
});
});
1 change: 1 addition & 0 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ const PDFViewerApplication = {
pageColorsBackground: x => x,
pageColorsForeground: x => x,
localeProperties: x => ({ lang: x }),
sidebarViewOnLoad: x => parseInt(x),
});
}

Expand Down
4 changes: 4 additions & 0 deletions web/pdf_thumbnail_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,10 @@ class PDFThumbnailViewer {
offsetWidth: w,
offsetHeight: h,
} = div;
if (w === 0) {
// The thumbnail view isn't visible.
return;
}
bbox[i * 4] = x;
bbox[i * 4 + 1] = y;
bbox[i * 4 + 2] = w;
Expand Down