2020-12-01 02:11:28 +09:00
|
|
|
/* Copyright 2020 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-12-11 06:45:14 +09:00
|
|
|
const { closePages, loadAndWait } = require("./test_utils.js");
|
|
|
|
|
2020-12-01 02:11:28 +09:00
|
|
|
describe("Annotation highlight", () => {
|
|
|
|
describe("annotation-highlight.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2020-12-11 06:45:14 +09:00
|
|
|
pages = await loadAndWait(
|
|
|
|
"annotation-highlight.pdf",
|
|
|
|
"[data-annotation-id='19R']"
|
2020-12-01 02:11:28 +09:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
2020-12-11 06:45:14 +09:00
|
|
|
await closePages(pages);
|
2020-12-01 02:11:28 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
it("must show a popup on mouseover", async () => {
|
|
|
|
await Promise.all(
|
2020-12-11 06:45:14 +09:00
|
|
|
pages.map(async ([browserName, page]) => {
|
2020-12-01 02:11:28 +09:00
|
|
|
let hidden = await page.$eval(
|
|
|
|
"[data-annotation-id='21R']",
|
|
|
|
el => el.hidden
|
|
|
|
);
|
2020-12-11 06:45:14 +09:00
|
|
|
expect(hidden).withContext(`In ${browserName}`).toEqual(true);
|
2020-12-01 02:11:28 +09:00
|
|
|
await page.hover("[data-annotation-id='19R']");
|
|
|
|
await page.waitForTimeout(100);
|
|
|
|
hidden = await page.$eval(
|
|
|
|
"[data-annotation-id='21R']",
|
|
|
|
el => el.hidden
|
|
|
|
);
|
2020-12-11 06:45:14 +09:00
|
|
|
expect(hidden).withContext(`In ${browserName}`).toEqual(false);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("Checkbox annotation", () => {
|
|
|
|
describe("issue12706.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("issue12706.pdf", "[data-annotation-id='63R']");
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must let checkboxes with the same name behave like radio buttons", async () => {
|
|
|
|
const selectors = [63, 70, 79].map(n => `[data-annotation-id='${n}R']`);
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
for (const selector of selectors) {
|
|
|
|
await page.click(selector);
|
|
|
|
for (const otherSelector of selectors) {
|
|
|
|
const checked = await page.$eval(
|
|
|
|
`${otherSelector} > :first-child`,
|
|
|
|
el => el.checked
|
|
|
|
);
|
|
|
|
expect(checked)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toBe(selector === otherSelector);
|
|
|
|
}
|
|
|
|
}
|
2020-12-01 02:11:28 +09:00
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|