mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-25 08:27:19 +02:00
Add some aria-labels to the paste button in order to know where the buttons are (bug 2020758)
This commit is contained in:
parent
68cca32e20
commit
18bafeb1c6
@ -767,4 +767,9 @@ pdfjs-views-manager-status-undo-button-label = Undo
|
|||||||
pdfjs-views-manager-status-close-button =
|
pdfjs-views-manager-status-close-button =
|
||||||
.title = Close
|
.title = Close
|
||||||
pdfjs-views-manager-status-close-button-label = Close
|
pdfjs-views-manager-status-close-button-label = Close
|
||||||
pdfjs-views-manager-paste-button-label = Paste
|
|
||||||
|
# Variables:
|
||||||
|
# $page (Number) - the page number after which the paste button is.
|
||||||
|
pdfjs-views-manager-paste-button-after-label = Paste after page { $page }
|
||||||
|
|
||||||
|
pdfjs-views-manager-paste-button-before-label = Paste before the first page
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import {
|
|||||||
createPromise,
|
createPromise,
|
||||||
createPromiseWithArgs,
|
createPromiseWithArgs,
|
||||||
dragAndDrop,
|
dragAndDrop,
|
||||||
|
FSI,
|
||||||
getAnnotationSelector,
|
getAnnotationSelector,
|
||||||
getRect,
|
getRect,
|
||||||
getThumbnailSelector,
|
getThumbnailSelector,
|
||||||
@ -27,6 +28,7 @@ import {
|
|||||||
kbCut,
|
kbCut,
|
||||||
kbDelete,
|
kbDelete,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
|
PDI,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
showViewsManager,
|
showViewsManager,
|
||||||
waitAndClick,
|
waitAndClick,
|
||||||
@ -792,6 +794,42 @@ describe("Reorganize Pages View", () => {
|
|||||||
await closePages(pages);
|
await closePages(pages);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should check that the paste button spans have the right l10n id depending on their position", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await waitForThumbnailVisible(page, 1);
|
||||||
|
await page.waitForSelector("#viewsManagerStatusActionButton", {
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
await waitAndClick(
|
||||||
|
page,
|
||||||
|
`.thumbnail:has(${getThumbnailSelector(1)}) input`
|
||||||
|
);
|
||||||
|
|
||||||
|
const handlePagesEdited = await waitForPagesEdited(page);
|
||||||
|
await waitAndClick(page, "#viewsManagerStatusActionButton");
|
||||||
|
await waitAndClick(page, "#viewsManagerStatusActionCopy");
|
||||||
|
await awaitPromise(handlePagesEdited);
|
||||||
|
|
||||||
|
const prevSpanText = await page.$eval(
|
||||||
|
`button.thumbnailPasteButton:has(+ ${getThumbnailSelector(1)}) > span`,
|
||||||
|
el => el.textContent.trim()
|
||||||
|
);
|
||||||
|
expect(prevSpanText)
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toBe("Paste before the first page");
|
||||||
|
|
||||||
|
const afterSpanText = await page.$eval(
|
||||||
|
`${getThumbnailSelector(1)} + button.thumbnailPasteButton > span`,
|
||||||
|
el => el.textContent.trim()
|
||||||
|
);
|
||||||
|
expect(afterSpanText)
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toBe(`Paste after page ${FSI}1${PDI}`);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("should check that a page can be copied and pasted before the first thumbnail", async () => {
|
it("should check that a page can be copied and pasted before the first thumbnail", async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
pages.map(async ([browserName, page]) => {
|
pages.map(async ([browserName, page]) => {
|
||||||
|
|||||||
@ -183,7 +183,16 @@ class PDFThumbnailView extends RenderableView {
|
|||||||
pasteButton.classList.add("thumbnailPasteButton", "viewsManagerButton");
|
pasteButton.classList.add("thumbnailPasteButton", "viewsManagerButton");
|
||||||
pasteButton.tabIndex = 0;
|
pasteButton.tabIndex = 0;
|
||||||
const span = document.createElement("span");
|
const span = document.createElement("span");
|
||||||
span.setAttribute("data-l10n-id", "pdfjs-views-manager-paste-button-label");
|
span.setAttribute(
|
||||||
|
"data-l10n-id",
|
||||||
|
"pdfjs-views-manager-paste-button-after-label"
|
||||||
|
);
|
||||||
|
span.setAttribute(
|
||||||
|
"data-l10n-args",
|
||||||
|
JSON.stringify({
|
||||||
|
page: this.pageLabel ?? this.id,
|
||||||
|
})
|
||||||
|
);
|
||||||
pasteButton.append(span);
|
pasteButton.append(span);
|
||||||
pasteButton.addEventListener("click", () => {
|
pasteButton.addEventListener("click", () => {
|
||||||
pasteCallback(this.id);
|
pasteCallback(this.id);
|
||||||
@ -191,6 +200,11 @@ class PDFThumbnailView extends RenderableView {
|
|||||||
if (this.id === 1) {
|
if (this.id === 1) {
|
||||||
const prevPasteButton = (this.prevPasteButton =
|
const prevPasteButton = (this.prevPasteButton =
|
||||||
pasteButton.cloneNode(true));
|
pasteButton.cloneNode(true));
|
||||||
|
const prevSpan = prevPasteButton.firstElementChild;
|
||||||
|
prevSpan.setAttribute(
|
||||||
|
"data-l10n-id",
|
||||||
|
"pdfjs-views-manager-paste-button-before-label"
|
||||||
|
);
|
||||||
prevPasteButton.addEventListener("click", () => {
|
prevPasteButton.addEventListener("click", () => {
|
||||||
pasteCallback(0);
|
pasteCallback(0);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user