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.
|
|
|
|
*/
|
|
|
|
|
2023-10-12 20:16:58 +09:00
|
|
|
import {
|
2022-06-18 05:01:20 +09:00
|
|
|
clearInput,
|
|
|
|
closePages,
|
2023-11-13 19:05:03 +09:00
|
|
|
getAnnotationStorage,
|
2022-06-18 05:01:20 +09:00
|
|
|
getComputedStyleSelector,
|
2023-07-30 01:15:23 +09:00
|
|
|
getFirstSerialized,
|
2023-10-12 20:16:58 +09:00
|
|
|
getQuerySelector,
|
|
|
|
getSelector,
|
2023-10-27 05:42:41 +09:00
|
|
|
kbDeleteLastWord,
|
|
|
|
kbSelectAll,
|
2023-10-12 20:16:58 +09:00
|
|
|
loadAndWait,
|
2023-09-28 05:35:57 +09:00
|
|
|
scrollIntoView,
|
2023-11-13 19:05:03 +09:00
|
|
|
waitForEntryInStorage,
|
2023-10-12 20:16:58 +09:00
|
|
|
} from "./test_utils.mjs";
|
2020-12-11 06:45:14 +09:00
|
|
|
|
2020-12-01 02:11:28 +09:00
|
|
|
describe("Interaction", () => {
|
2021-01-05 23:53:30 +09:00
|
|
|
async function actAndWaitForInput(page, selector, action, clear = true) {
|
2022-10-25 22:28:22 +09:00
|
|
|
await page.waitForSelector(selector, {
|
|
|
|
timeout: 0,
|
|
|
|
});
|
2021-01-05 23:53:30 +09:00
|
|
|
if (clear) {
|
|
|
|
await clearInput(page, selector);
|
|
|
|
}
|
2020-12-24 02:57:44 +09:00
|
|
|
await action();
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`document.querySelector('${selector}').value !== ""`
|
2020-12-24 02:57:44 +09:00
|
|
|
);
|
|
|
|
return page.$eval(selector, el => el.value);
|
|
|
|
}
|
|
|
|
|
2020-12-01 02:11:28 +09:00
|
|
|
describe("in 160F-2019.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("160F-2019.pdf", getSelector("416R"));
|
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
|
|
|
});
|
|
|
|
|
2020-12-08 03:22:14 +09:00
|
|
|
it("must check that first text field has focus", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
2020-12-19 07:12:52 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
2022-10-02 00:50:58 +09:00
|
|
|
await page.waitForFunction(`window.document.activeElement !== null`);
|
2020-12-19 07:12:52 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
// The document has an open action in order to give the focus to 401R.
|
|
|
|
const id = await page.evaluate(() => {
|
|
|
|
const element = window.document.activeElement;
|
|
|
|
return element.getAttribute("data-element-id");
|
|
|
|
});
|
2020-12-08 03:22:14 +09:00
|
|
|
expect(id).withContext(`In ${browserName}`).toEqual("401R");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2020-11-18 22:59:57 +09:00
|
|
|
it("must show a text field and then make in invisible when content is removed", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
let visibility = await page.$eval(
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector("427R"),
|
2020-11-18 22:59:57 +09:00
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility).withContext(`In ${browserName}`).toEqual("hidden");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.type(getSelector("416R"), "3.14159", { delay: 200 });
|
|
|
|
await page.click(getSelector("419R"));
|
2020-11-18 22:59:57 +09:00
|
|
|
|
2021-05-08 22:36:16 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getComputedStyleSelector("427R")}.visibility !== "hidden"`
|
2021-05-08 22:36:16 +09:00
|
|
|
);
|
|
|
|
|
2020-11-18 22:59:57 +09:00
|
|
|
visibility = await page.$eval(
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector("427R"),
|
2020-11-18 22:59:57 +09:00
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual("visible");
|
|
|
|
|
|
|
|
// Clear the textfield
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("416R"));
|
2020-11-18 22:59:57 +09:00
|
|
|
// and leave it
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.click(getSelector("419R"));
|
2020-11-18 22:59:57 +09:00
|
|
|
|
2021-05-08 22:36:16 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getComputedStyleSelector("427R")}.visibility !== "visible"`
|
2021-05-08 22:36:16 +09:00
|
|
|
);
|
|
|
|
|
2020-11-18 22:59:57 +09:00
|
|
|
visibility = await page.$eval(
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector("427R"),
|
2020-11-18 22:59:57 +09:00
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility).withContext(`In ${browserName}`).toEqual("hidden");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2020-12-01 02:11:28 +09:00
|
|
|
it("must format the field with 2 digits and leave field with a click", async () => {
|
|
|
|
await Promise.all(
|
2020-12-11 06:45:14 +09:00
|
|
|
pages.map(async ([browserName, page]) => {
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.type(getSelector("416R"), "3.14159", { delay: 200 });
|
|
|
|
await page.click(getSelector("419R"));
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const valueFnStr = `${getQuerySelector("416R")}.value !== "3.14159"`;
|
|
|
|
await page.waitForFunction(valueFnStr);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("416R"), el => el.value);
|
2020-12-11 06:45:14 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("3,14");
|
2020-11-18 22:59:57 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const sum = await page.$eval(getSelector("427R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(sum).withContext(`In ${browserName}`).toEqual("3,14");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must format the field with 2 digits, leave field with a click and again", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.type(getSelector("448R"), "61803", { delay: 200 });
|
|
|
|
await page.click(getSelector("419R"));
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const valueOneFnStr = `${getQuerySelector("448R")}.value !== "61803"`;
|
|
|
|
await page.waitForFunction(valueOneFnStr);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
let text = await page.$eval(getSelector("448R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("61.803,00");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.click(getSelector("448R"));
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const valueTwoFnStr = `${getQuerySelector(
|
|
|
|
"448R"
|
|
|
|
)}.value !== "61.803,00"`;
|
|
|
|
await page.waitForFunction(valueTwoFnStr);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("448R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("61803");
|
|
|
|
|
|
|
|
// Clear the textfield
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("448R"));
|
2020-11-18 22:59:57 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.type(getSelector("448R"), "1.61803", { delay: 200 });
|
|
|
|
await page.click(getSelector("419R"));
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const valueThreeFnStr = `${getQuerySelector(
|
|
|
|
"448R"
|
|
|
|
)}.value !== "1.61803"`;
|
|
|
|
await page.waitForFunction(valueThreeFnStr);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("448R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("1,62");
|
2020-12-01 02:11:28 +09:00
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must format the field with 2 digits and leave field with a TAB", async () => {
|
|
|
|
await Promise.all(
|
2020-12-11 06:45:14 +09:00
|
|
|
pages.map(async ([browserName, page]) => {
|
2022-06-18 05:01:20 +09:00
|
|
|
const prevSum = await page.$eval(getSelector("427R"), el => el.value);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.type(getSelector("422R"), "2.7182818", { delay: 200 });
|
2020-12-01 02:11:28 +09:00
|
|
|
await page.keyboard.press("Tab");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("422R")}.value !== "2.7182818"`
|
2022-01-09 01:57:06 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("422R"), el => el.value);
|
2020-12-11 06:45:14 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("2,72");
|
2020-11-18 22:59:57 +09:00
|
|
|
|
2022-01-09 01:57:06 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("427R")}.value !== "${prevSum}"`
|
2022-01-09 01:57:06 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const sum = await page.$eval(getSelector("427R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(sum).withContext(`In ${browserName}`).toEqual("5,86");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must format the field with 2 digits and hit ESC", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
2022-06-18 05:01:20 +09:00
|
|
|
let sum = await page.$eval(getSelector("471R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(sum).withContext(`In ${browserName}`).toEqual("4,24");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.type(getSelector("436R"), "0.69314", { delay: 200 });
|
2020-11-18 22:59:57 +09:00
|
|
|
await page.keyboard.press("Escape");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("436R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("0.69314");
|
|
|
|
|
2022-01-09 01:57:06 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("471R")}.value !== "${sum}"`
|
2022-01-09 01:57:06 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
sum = await page.$eval(getSelector("471R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(sum).withContext(`In ${browserName}`).toEqual("3,55");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must format the field with 2 digits on key ENTER", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
2022-06-18 05:01:20 +09:00
|
|
|
const prevSum = await page.$eval(getSelector("427R"), el => el.value);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.type(getSelector("419R"), "0.577215", { delay: 200 });
|
2020-11-18 22:59:57 +09:00
|
|
|
await page.keyboard.press("Enter");
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("419R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(text).toEqual("0.577215");
|
|
|
|
|
2022-01-09 01:57:06 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("427R")}.value !== "${prevSum}"`
|
2022-01-09 01:57:06 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const sum = await page.$eval(getSelector("427R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(sum).toEqual("6,44");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must reset all", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
2021-03-07 01:19:57 +09:00
|
|
|
// click on a radio button
|
|
|
|
await page.click("[data-annotation-id='449R']");
|
|
|
|
|
2020-11-18 22:59:57 +09:00
|
|
|
// this field has no actions but it must be cleared on reset
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.type(getSelector("405R"), "employee", { delay: 200 });
|
2020-11-18 22:59:57 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
let checked = await page.$eval(getSelector("449R"), el => el.checked);
|
2021-03-07 01:19:57 +09:00
|
|
|
expect(checked).toEqual(true);
|
|
|
|
|
2020-11-18 22:59:57 +09:00
|
|
|
// click on reset button
|
|
|
|
await page.click("[data-annotation-id='402R']");
|
|
|
|
|
2022-01-09 01:57:06 +09:00
|
|
|
await Promise.all(
|
2022-06-18 05:01:20 +09:00
|
|
|
["416R", "422R", "419R", "405R"].map(id => {
|
|
|
|
const querySelector = getQuerySelector(id);
|
|
|
|
return page.waitForFunction(`${querySelector}.value === ""`);
|
|
|
|
})
|
2022-01-09 01:57:06 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
let text = await page.$eval(getSelector("416R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(text).toEqual("");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("422R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(text).toEqual("");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("419R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(text).toEqual("");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("405R"), el => el.value);
|
2020-11-18 22:59:57 +09:00
|
|
|
expect(text).toEqual("");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
checked = await page.$eval(getSelector("449R"), el => el.checked);
|
2021-03-07 01:19:57 +09:00
|
|
|
expect(checked).toEqual(false);
|
2022-05-03 02:28:00 +09:00
|
|
|
|
|
|
|
const visibility = await page.$eval(
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector("427R"),
|
2022-05-03 02:28:00 +09:00
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility).toEqual("hidden");
|
2020-12-01 02:11:28 +09:00
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2020-11-19 02:54:26 +09:00
|
|
|
|
|
|
|
describe("in js-buttons.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("js-buttons.pdf", getSelector("80R"));
|
2020-11-19 02:54:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must show values in a text input when clicking on radio buttons", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
const expected = [
|
2022-06-18 05:01:20 +09:00
|
|
|
["81R", "Group1=Choice1::1"],
|
|
|
|
["82R", "Group1=Choice2::2"],
|
|
|
|
["83R", "Group1=Choice3::3"],
|
|
|
|
["84R", "Group1=Choice4::4"],
|
2020-11-19 02:54:26 +09:00
|
|
|
];
|
2022-06-18 05:01:20 +09:00
|
|
|
for (const [id, expectedText] of expected) {
|
2020-11-19 02:54:26 +09:00
|
|
|
// Clear the textfield
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("80R"));
|
2020-11-19 02:54:26 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.click(getSelector(id));
|
2020-11-19 02:54:26 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("80R")}.value !== ""`
|
2020-11-19 02:54:26 +09:00
|
|
|
);
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("80R"), el => el.value);
|
2020-11-19 02:54:26 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual(expectedText);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must show values in a text input when clicking on checkboxes", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
const expected = [
|
2022-06-18 05:01:20 +09:00
|
|
|
["85R", "Check1=Yes::5"],
|
|
|
|
["87R", "Check2=Yes::6"],
|
|
|
|
["88R", "Check3=Yes::7"],
|
|
|
|
["89R", "Check4=Yes::8"],
|
|
|
|
["85R", "Check1=Off::5"],
|
|
|
|
["87R", "Check2=Off::6"],
|
|
|
|
["88R", "Check3=Off::7"],
|
|
|
|
["89R", "Check4=Off::8"],
|
2020-11-19 02:54:26 +09:00
|
|
|
];
|
2022-06-18 05:01:20 +09:00
|
|
|
for (const [id, expectedText] of expected) {
|
2020-11-19 02:54:26 +09:00
|
|
|
// Clear the textfield
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("80R"));
|
2020-11-19 02:54:26 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.click(getSelector(id));
|
2020-11-19 02:54:26 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("80R")}.value !== ""`
|
2020-11-19 02:54:26 +09:00
|
|
|
);
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("80R"), el => el.value);
|
2020-11-19 02:54:26 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual(expectedText);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must show values in a text input when clicking on checkboxes in a group", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
const expected = [
|
2022-06-18 05:01:20 +09:00
|
|
|
["90R", "Check5=Yes1::9"],
|
|
|
|
["91R", "Check5=Yes2::10"],
|
|
|
|
["92R", "Check5=Yes3::11"],
|
|
|
|
["93R", "Check5=Yes4::12"],
|
|
|
|
["93R", "Check5=Off::12"],
|
2020-11-19 02:54:26 +09:00
|
|
|
];
|
2022-06-18 05:01:20 +09:00
|
|
|
for (const [id, expectedText] of expected) {
|
2020-11-19 02:54:26 +09:00
|
|
|
// Clear the textfield
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("80R"));
|
2020-11-19 02:54:26 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.click(getSelector(id));
|
2020-11-19 02:54:26 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("80R")}.value !== ""`
|
2020-11-19 02:54:26 +09:00
|
|
|
);
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("80R"), el => el.value);
|
2021-01-09 00:43:16 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual(expectedText);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must show values in a text input when clicking on checkboxes or radio with no actions", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
const expected = [
|
|
|
|
["", "Off;Off"],
|
2022-06-18 05:01:20 +09:00
|
|
|
["94R", "Yes;Off"],
|
|
|
|
["95R", "Yes;NoAct2"],
|
|
|
|
["96R", "Yes;NoAct3"],
|
|
|
|
["94R", "Off;NoAct3"],
|
|
|
|
["95R", "Off;NoAct2"],
|
2021-01-09 00:43:16 +09:00
|
|
|
];
|
2022-06-18 05:01:20 +09:00
|
|
|
for (const [id, expectedText] of expected) {
|
2021-01-09 00:43:16 +09:00
|
|
|
// Clear the textfield
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("80R"));
|
2021-01-09 00:43:16 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
if (id) {
|
|
|
|
await page.click(getSelector(id));
|
2021-01-09 00:43:16 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
await page.click("[data-annotation-id='97R']");
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("80R")}.value !== ""`
|
2021-01-09 00:43:16 +09:00
|
|
|
);
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("80R"), el => el.value);
|
2020-11-19 02:54:26 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual(expectedText);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2020-12-24 02:57:44 +09:00
|
|
|
|
|
|
|
describe("in doc_actions.pdf for printing", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("doc_actions.pdf", getSelector("47R"));
|
2020-12-24 02:57:44 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must execute WillPrint and DidPrint actions", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
if (process.platform === "win32" && browserName === "firefox") {
|
2021-01-04 02:59:19 +09:00
|
|
|
pending("Disabled in Firefox on Windows, because of bug 1662471.");
|
2020-12-24 02:57:44 +09:00
|
|
|
}
|
2021-01-05 23:53:30 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("47R"));
|
2021-01-05 23:53:30 +09:00
|
|
|
await page.evaluate(_ => {
|
|
|
|
window.document.activeElement.blur();
|
|
|
|
});
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.waitForFunction(`${getQuerySelector("47R")}.value === ""`);
|
2021-01-05 23:53:30 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
let text = await actAndWaitForInput(
|
|
|
|
page,
|
|
|
|
getSelector("47R"),
|
|
|
|
async () => {
|
|
|
|
await page.click("#print");
|
|
|
|
}
|
|
|
|
);
|
2020-12-24 02:57:44 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("WillPrint");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.waitForFunction(`${getQuerySelector("50R")}.value !== ""`);
|
2020-12-24 02:57:44 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("50R"), el => el.value);
|
2020-12-24 02:57:44 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("DidPrint");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("in doc_actions.pdf for saving", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("doc_actions.pdf", getSelector("47R"));
|
2020-12-24 02:57:44 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must execute WillSave and DidSave actions", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
2021-01-05 23:53:30 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
2020-12-24 02:57:44 +09:00
|
|
|
try {
|
|
|
|
// Disable download in chrome
|
|
|
|
// (it leads to an error in firefox so the try...)
|
|
|
|
await page._client.send("Page.setDownloadBehavior", {
|
|
|
|
behavior: "deny",
|
|
|
|
});
|
2023-06-12 18:46:11 +09:00
|
|
|
} catch {}
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("47R"));
|
2021-01-05 23:53:30 +09:00
|
|
|
await page.evaluate(_ => {
|
|
|
|
window.document.activeElement.blur();
|
|
|
|
});
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.waitForFunction(`${getQuerySelector("47R")}.value === ""`);
|
2021-01-05 23:53:30 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
let text = await actAndWaitForInput(
|
|
|
|
page,
|
|
|
|
getSelector("47R"),
|
|
|
|
async () => {
|
|
|
|
await page.click("#download");
|
|
|
|
}
|
|
|
|
);
|
2020-12-24 02:57:44 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("WillSave");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.waitForFunction(`${getQuerySelector("50R")}.value !== ""`);
|
2020-12-24 02:57:44 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("50R"), el => el.value);
|
2020-12-24 02:57:44 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("DidSave");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-01-05 23:53:30 +09:00
|
|
|
|
|
|
|
describe("in doc_actions.pdf for page actions", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("doc_actions.pdf", getSelector("47R"));
|
2021-01-05 23:53:30 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must execute PageOpen and PageClose actions", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.waitForFunction(`${getQuerySelector("47R")}.value !== ""`);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
let text = await page.$eval(getSelector("47R"), el => el.value);
|
2021-01-05 23:53:30 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("PageOpen 1");
|
|
|
|
|
|
|
|
for (let run = 0; run < 5; run++) {
|
2022-06-18 05:01:20 +09:00
|
|
|
for (const ref of ["18R", "19R", "20R", "21R", "47R", "50R"]) {
|
|
|
|
await page.evaluate(selector => {
|
|
|
|
const element = window.document.querySelector(selector);
|
2021-01-05 23:53:30 +09:00
|
|
|
if (element) {
|
|
|
|
element.value = "";
|
|
|
|
}
|
2022-06-18 05:01:20 +09:00
|
|
|
}, getSelector(ref));
|
2021-01-05 23:53:30 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
for (const [refOpen, refClose, pageNumOpen, pageNumClose] of [
|
2022-06-18 05:01:20 +09:00
|
|
|
["18R", "50R", 2, 1],
|
|
|
|
["21R", "19R", 3, 2],
|
|
|
|
["47R", "20R", 1, 3],
|
2021-01-05 23:53:30 +09:00
|
|
|
]) {
|
|
|
|
text = await actAndWaitForInput(
|
|
|
|
page,
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector(refOpen),
|
2023-09-28 05:35:57 +09:00
|
|
|
() => scrollIntoView(page, getSelector(refOpen)),
|
2021-01-05 23:53:30 +09:00
|
|
|
false
|
|
|
|
);
|
|
|
|
expect(text)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(`PageOpen ${pageNumOpen}`);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector(refClose), el => el.value);
|
2021-01-05 23:53:30 +09:00
|
|
|
expect(text)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(`PageClose ${pageNumClose}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-01-09 02:40:09 +09:00
|
|
|
|
|
|
|
describe("in js-authors.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("js-authors.pdf", getSelector("25R"));
|
2021-01-09 02:40:09 +09:00
|
|
|
});
|
|
|
|
|
2021-05-06 02:05:08 +09:00
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
2021-01-09 02:40:09 +09:00
|
|
|
it("must print authors in a text field", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await actAndWaitForInput(
|
|
|
|
page,
|
|
|
|
getSelector("25R"),
|
|
|
|
async () => {
|
|
|
|
await page.click("[data-annotation-id='26R']");
|
|
|
|
}
|
|
|
|
);
|
2021-01-09 02:40:09 +09:00
|
|
|
expect(text)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual("author1::author2::author3::author4::author5");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-01-26 07:40:57 +09:00
|
|
|
|
|
|
|
describe("in listbox_actions.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("listbox_actions.pdf", getSelector("33R"));
|
2021-01-26 07:40:57 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must print selected value in a text field", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
for (const num of [7, 6, 4, 3, 2, 1]) {
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("33R"));
|
2021-01-26 07:40:57 +09:00
|
|
|
await page.click(`option[value=Export${num}]`);
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("33R")}.value !== ""`
|
2021-01-26 07:40:57 +09:00
|
|
|
);
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("33R"), el => el.value);
|
2021-01-26 07:40:57 +09:00
|
|
|
expect(text)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(`Item${num},Export${num}`);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must clear and restore list elements", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
// Click on ClearItems button.
|
|
|
|
await page.click("[data-annotation-id='34R']");
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("30R")}.children.length === 0`
|
2021-01-26 07:40:57 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
// Click on Restore button.
|
|
|
|
await page.click("[data-annotation-id='37R']");
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("30R")}.children.length !== 0`
|
2021-01-26 07:40:57 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
for (const num of [7, 6, 4, 3, 2, 1]) {
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("33R"));
|
2021-01-26 07:40:57 +09:00
|
|
|
await page.click(`option[value=Export${num}]`);
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("33R")}.value !== ""`
|
2021-01-26 07:40:57 +09:00
|
|
|
);
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("33R"), el => el.value);
|
2021-01-26 07:40:57 +09:00
|
|
|
expect(text)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(`Item${num},Export${num}`);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must insert new elements", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
let len = 6;
|
|
|
|
for (const num of [1, 3, 5, 6, 431, -1, 0]) {
|
|
|
|
++len;
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("33R"));
|
|
|
|
await clearInput(page, getSelector("39R"));
|
|
|
|
await page.type(
|
|
|
|
getSelector("39R"),
|
|
|
|
`${num},Insert${num},Tresni${num}`,
|
|
|
|
{
|
|
|
|
delay: 10,
|
|
|
|
}
|
|
|
|
);
|
2021-01-26 07:40:57 +09:00
|
|
|
|
|
|
|
// Click on AddItem button.
|
|
|
|
await page.click("[data-annotation-id='38R']");
|
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("30R")}.children.length === ${len}`
|
2021-01-26 07:40:57 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
// Click on newly added option.
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.select(getSelector("30R"), `Tresni${num}`);
|
2021-01-26 07:40:57 +09:00
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("33R")}.value !== ""`
|
2021-01-26 07:40:57 +09:00
|
|
|
);
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("33R"), el => el.value);
|
2021-01-26 07:40:57 +09:00
|
|
|
expect(text)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(`Insert${num},Tresni${num}`);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must delete some element", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
let len = 6;
|
|
|
|
// Click on Restore button.
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("33R"));
|
2021-01-26 07:40:57 +09:00
|
|
|
await page.click("[data-annotation-id='37R']");
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("30R")}.children.length === ${len}`
|
2021-01-26 07:40:57 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
for (const num of [2, 5]) {
|
|
|
|
--len;
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("39R"));
|
|
|
|
await page.type(getSelector("39R"), `${num}`);
|
2021-01-26 07:40:57 +09:00
|
|
|
|
|
|
|
// Click on DeleteItem button.
|
|
|
|
await page.click("[data-annotation-id='36R']");
|
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("30R")}.children.length === ${len}`
|
2021-01-26 07:40:57 +09:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const num of [6, 4, 2, 1]) {
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("33R"));
|
2021-01-26 07:40:57 +09:00
|
|
|
await page.click(`option[value=Export${num}]`);
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("33R")}.value !== ""`
|
2021-01-26 07:40:57 +09:00
|
|
|
);
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("33R"), el => el.value);
|
2021-01-26 07:40:57 +09:00
|
|
|
expect(text)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(`Item${num},Export${num}`);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-02-20 23:23:54 +09:00
|
|
|
|
|
|
|
describe("in js-colors.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("js-colors.pdf", getSelector("34R"));
|
2021-02-20 23:23:54 +09:00
|
|
|
});
|
|
|
|
|
2021-05-06 02:05:08 +09:00
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
2021-02-26 08:16:19 +09:00
|
|
|
it("must change colors", async () => {
|
2021-02-20 23:23:54 +09:00
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
for (const [name, ref] of [
|
2022-06-18 05:01:20 +09:00
|
|
|
["Text1", "34R"],
|
|
|
|
["Check1", "35R"],
|
|
|
|
["Radio1", "37R"],
|
|
|
|
["Choice1", "38R"],
|
2021-02-20 23:23:54 +09:00
|
|
|
]) {
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("34R"));
|
|
|
|
await page.type(getSelector("34R"), `${name}`, {
|
2021-02-20 23:23:54 +09:00
|
|
|
delay: 10,
|
|
|
|
});
|
|
|
|
|
2023-07-30 01:15:23 +09:00
|
|
|
for (const [id, propName, storedName, expected, storedExpected] of [
|
|
|
|
[
|
|
|
|
41,
|
|
|
|
"backgroundColor",
|
|
|
|
"backgroundColor",
|
|
|
|
"rgb(255, 0, 0)",
|
|
|
|
[255, 0, 0],
|
|
|
|
],
|
|
|
|
[43, "color", "color", "rgb(0, 255, 0)", [0, 255, 0]],
|
|
|
|
[
|
|
|
|
44,
|
|
|
|
"border-top-color",
|
|
|
|
"borderColor",
|
|
|
|
"rgb(0, 0, 255)",
|
|
|
|
[0, 0, 255],
|
|
|
|
],
|
2021-02-26 08:16:19 +09:00
|
|
|
]) {
|
|
|
|
const current = await page.$eval(
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector(ref),
|
2021-02-26 08:16:19 +09:00
|
|
|
(el, _propName) => getComputedStyle(el)[_propName],
|
|
|
|
propName
|
|
|
|
);
|
2021-02-20 23:23:54 +09:00
|
|
|
|
2021-02-26 08:16:19 +09:00
|
|
|
await page.click(`[data-annotation-id='${id}R']`);
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getComputedStyleSelector(
|
|
|
|
ref
|
|
|
|
)}["${propName}"] !== "${current}"`
|
2021-02-26 08:16:19 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
const color = await page.$eval(
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector(ref),
|
2021-02-26 08:16:19 +09:00
|
|
|
(el, _propName) => getComputedStyle(el)[_propName],
|
|
|
|
propName
|
|
|
|
);
|
|
|
|
expect(color).withContext(`In ${browserName}`).toEqual(expected);
|
2023-07-30 01:15:23 +09:00
|
|
|
|
|
|
|
const storedValue = (await getFirstSerialized(page))[storedName];
|
|
|
|
expect(storedValue)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(storedExpected);
|
2021-02-26 08:16:19 +09:00
|
|
|
}
|
2021-02-20 23:23:54 +09:00
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-03-31 00:50:35 +09:00
|
|
|
|
|
|
|
describe("in issue13132.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("issue13132.pdf", getSelector("171R"));
|
2021-03-31 00:50:35 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must compute sum of fields", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
2023-10-30 02:20:58 +09:00
|
|
|
await scrollIntoView(page, getSelector("138R"));
|
2021-03-31 00:50:35 +09:00
|
|
|
|
|
|
|
let sum = 0;
|
|
|
|
for (const [id, val] of [
|
2022-06-18 05:01:20 +09:00
|
|
|
["138R", 1],
|
|
|
|
["77R", 2],
|
|
|
|
["93R", 3],
|
|
|
|
["151R", 4],
|
|
|
|
["79R", 5],
|
2021-03-31 00:50:35 +09:00
|
|
|
]) {
|
2022-06-18 05:01:20 +09:00
|
|
|
const prev = await page.$eval(getSelector("171R"), el => el.value);
|
2021-03-31 00:50:35 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.type(getSelector(id), val.toString(), {
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
delay: 200,
|
2022-06-18 05:01:20 +09:00
|
|
|
});
|
2021-03-31 00:50:35 +09:00
|
|
|
await page.keyboard.press("Tab");
|
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("171R")}.value !== "${prev}"`
|
2021-03-31 00:50:35 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
sum += val;
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const total = await page.$eval(getSelector("171R"), el => el.value);
|
2021-03-31 00:50:35 +09:00
|
|
|
expect(total).withContext(`In ${browserName}`).toEqual(`£${sum}`);
|
|
|
|
}
|
|
|
|
|
2023-04-25 18:35:21 +09:00
|
|
|
await page.waitForSelector('.page[data-page-number = "4"]', {
|
|
|
|
timeout: 0,
|
|
|
|
});
|
|
|
|
|
2021-03-31 00:50:35 +09:00
|
|
|
// Some unrendered annotations have been updated, so check
|
|
|
|
// that they've the correct value when rendered.
|
2023-09-28 05:35:57 +09:00
|
|
|
await scrollIntoView(page, '.page[data-page-number = "4"]');
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.waitForSelector(getSelector("299R"), {
|
2021-03-31 00:50:35 +09:00
|
|
|
timeout: 0,
|
|
|
|
});
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const total = await page.$eval(getSelector("299R"), el => el.value);
|
2021-03-31 00:50:35 +09:00
|
|
|
expect(total).withContext(`In ${browserName}`).toEqual(`£${sum}`);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-04-30 23:43:27 +09:00
|
|
|
|
|
|
|
describe("Check field properties", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("evaljs.pdf", getSelector("55R"));
|
2021-04-30 23:43:27 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check page index", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("55R"));
|
2021-04-30 23:43:27 +09:00
|
|
|
await page.type(
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector("55R"),
|
2021-04-30 23:43:27 +09:00
|
|
|
`
|
|
|
|
['Text1', 'Text2', 'Text4',
|
|
|
|
'List Box7', 'Group6'].map(x => this.getField(x).page).join(',')
|
2021-04-21 02:21:52 +09:00
|
|
|
`
|
2021-04-30 23:43:27 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
// Click on execute button to eval the above code.
|
|
|
|
await page.click("[data-annotation-id='57R']");
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.waitForFunction(`${getQuerySelector("56R")}.value !== ""`);
|
2021-04-30 23:43:27 +09:00
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await page.$eval(getSelector("56R"), el => el.value);
|
2021-04-30 23:43:27 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("0,0,1,1,1");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
2021-05-04 01:03:16 +09:00
|
|
|
|
|
|
|
it("must check display", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
for (const [type, vis] of [
|
|
|
|
["hidden", "hidden"],
|
|
|
|
["noPrint", "visible"],
|
|
|
|
["noView", "hidden"],
|
|
|
|
["visible", "visible"],
|
|
|
|
]) {
|
|
|
|
let visibility = await page.$eval(
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector("56R"),
|
2021-05-04 01:03:16 +09:00
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await clearInput(page, getSelector("55R"));
|
2021-05-04 01:03:16 +09:00
|
|
|
await page.type(
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector("55R"),
|
2021-05-04 01:03:16 +09:00
|
|
|
`this.getField("Text2").display = display.${type};`
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.click("[data-annotation-id='57R']");
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getComputedStyleSelector(
|
|
|
|
"56R"
|
|
|
|
)}.visibility !== "${visibility}"`
|
2021-05-04 01:03:16 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
visibility = await page.$eval(
|
2022-06-18 05:01:20 +09:00
|
|
|
getSelector("56R"),
|
2021-05-04 01:03:16 +09:00
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility).withContext(`In ${browserName}`).toEqual(vis);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
2021-04-30 23:43:27 +09:00
|
|
|
});
|
2021-04-21 02:21:52 +09:00
|
|
|
|
|
|
|
describe("in issue13269.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("issue13269.pdf", getSelector("27R"));
|
2021-04-21 02:21:52 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must update fields with the same name from JS", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.type(getSelector("27R"), "hello");
|
2021-04-21 02:21:52 +09:00
|
|
|
await page.keyboard.press("Enter");
|
|
|
|
|
|
|
|
await Promise.all(
|
2022-06-18 05:01:20 +09:00
|
|
|
["24R", "25R", "26R"].map(async id =>
|
|
|
|
page.waitForFunction(`${getQuerySelector(id)}.value !== ""`)
|
2021-04-21 02:21:52 +09:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
const expected = "hello world";
|
2022-06-18 05:01:20 +09:00
|
|
|
for (const id of ["24R", "25R", "26R"]) {
|
|
|
|
const text = await page.$eval(getSelector(id), el => el.value);
|
2021-04-21 02:21:52 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual(expected);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-10-25 23:09:26 +09:00
|
|
|
|
|
|
|
describe("in secHandler.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("secHandler.pdf", getSelector("25R"));
|
2021-10-25 23:09:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
it("must print securityHandler value in a text field", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
2022-06-18 05:01:20 +09:00
|
|
|
const text = await actAndWaitForInput(
|
|
|
|
page,
|
|
|
|
getSelector("25R"),
|
|
|
|
async () => {
|
|
|
|
await page.click("[data-annotation-id='26R']");
|
|
|
|
}
|
|
|
|
);
|
2021-10-25 23:09:26 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("Standard");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-01-09 01:57:06 +09:00
|
|
|
|
|
|
|
describe("in issue14307.pdf (1)", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("issue14307.pdf", getSelector("30R"));
|
2022-01-09 01:57:06 +09:00
|
|
|
pages.map(async ([, page]) => {
|
|
|
|
page.on("dialog", async dialog => {
|
|
|
|
await dialog.dismiss();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check input for US zip format", async () => {
|
2022-12-14 00:08:36 +09:00
|
|
|
// Run the tests sequentially to avoid any focus issues between the two
|
|
|
|
// browsers when an alert is displayed.
|
|
|
|
for (const [browserName, page] of pages) {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await clearInput(page, getSelector("29R"));
|
|
|
|
await clearInput(page, getSelector("30R"));
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.focus(getSelector("29R"));
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("29R"), "12A", { delay: 200 });
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("29R")}.value !== "12A"`
|
|
|
|
);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
let text = await page.$eval(getSelector(`29R`), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("12");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.focus(getSelector("29R"));
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("29R"), "34", { delay: 200 });
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.click("[data-annotation-id='30R']");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("29R")}.value !== "1234"`
|
|
|
|
);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
text = await page.$eval(getSelector(`29R`), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.focus(getSelector("29R"));
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("29R"), "12345", { delay: 200 });
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.click("[data-annotation-id='30R']");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
text = await page.$eval(getSelector(`29R`), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("12345");
|
|
|
|
}
|
2022-01-09 01:57:06 +09:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("in issue14307.pdf (2)", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("issue14307.pdf", getSelector("30R"));
|
2022-01-09 01:57:06 +09:00
|
|
|
pages.map(async ([, page]) => {
|
|
|
|
page.on("dialog", async dialog => {
|
|
|
|
await dialog.dismiss();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check input for US phone number (long) format", async () => {
|
2022-12-14 00:08:36 +09:00
|
|
|
// Run the tests sequentially to avoid any focus issues between the two
|
|
|
|
// browsers when an alert is displayed.
|
|
|
|
for (const [browserName, page] of pages) {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await clearInput(page, getSelector("29R"));
|
|
|
|
await clearInput(page, getSelector("30R"));
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.focus(getSelector("30R"));
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("30R"), "(123) 456A", { delay: 200 });
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("30R")}.value !== "(123) 456A"`
|
|
|
|
);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
let text = await page.$eval(getSelector(`30R`), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("(123) 456");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.focus(getSelector("30R"));
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("30R"), "-789", { delay: 200 });
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.click("[data-annotation-id='29R']");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("30R")}.value !== "(123) 456-789"`
|
|
|
|
);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
text = await page.$eval(getSelector(`30R`), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.focus(getSelector("30R"));
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("30R"), "(123) 456-7890", { delay: 200 });
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.click("[data-annotation-id='29R']");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
text = await page.$eval(getSelector("30R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("(123) 456-7890");
|
|
|
|
}
|
2022-01-09 01:57:06 +09:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("in issue14307.pdf (3)", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("issue14307.pdf", getSelector("30R"));
|
2022-01-09 01:57:06 +09:00
|
|
|
pages.map(async ([, page]) => {
|
|
|
|
page.on("dialog", async dialog => {
|
|
|
|
await dialog.dismiss();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check input for US phone number (short) format", async () => {
|
2022-12-14 00:08:36 +09:00
|
|
|
// Run the tests sequentially to avoid any focus issues between the two
|
|
|
|
// browsers when an alert is displayed.
|
|
|
|
for (const [browserName, page] of pages) {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await clearInput(page, getSelector("29R"));
|
|
|
|
await clearInput(page, getSelector("30R"));
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.focus(getSelector("30R"));
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("30R"), "123A", { delay: 200 });
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("30R")}.value !== "123A"`
|
|
|
|
);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
let text = await page.$eval(getSelector(`30R`), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("123");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.focus(getSelector("30R"));
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("30R"), "-456", { delay: 200 });
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.click("[data-annotation-id='29R']");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("30R")}.value !== "123-456"`
|
|
|
|
);
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
text = await page.$eval(getSelector("30R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.focus(getSelector("30R"));
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("30R"), "123-4567", { delay: 200 });
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.click("[data-annotation-id='29R']");
|
2022-01-09 01:57:06 +09:00
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
text = await page.$eval(getSelector("30R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("123-4567");
|
|
|
|
}
|
2022-01-09 01:57:06 +09:00
|
|
|
});
|
|
|
|
});
|
2022-05-03 02:28:00 +09:00
|
|
|
|
|
|
|
describe("in issue14862.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("issue14862.pdf", getSelector("27R"));
|
2022-05-03 02:28:00 +09:00
|
|
|
pages.map(async ([, page]) => {
|
|
|
|
page.on("dialog", async dialog => {
|
|
|
|
await dialog.dismiss();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
it("must convert input to uppercase", async () => {
|
2022-05-03 02:28:00 +09:00
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("27R"), "Hello", { delay: 200 });
|
2022-05-03 02:28:00 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("27R")}.value !== "Hello"`
|
2022-05-03 02:28:00 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
let text = await page.$eval(getSelector("27R"), el => el.value);
|
2022-05-03 02:28:00 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("HELLO");
|
|
|
|
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("27R"), " world", { delay: 200 });
|
2022-05-03 02:28:00 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("27R")}.value !== "HELLO world"`
|
2022-05-03 02:28:00 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("27R"), el => el.value);
|
2022-05-03 02:28:00 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("HELLO WORLD");
|
|
|
|
|
|
|
|
await page.keyboard.press("Backspace");
|
|
|
|
await page.keyboard.press("Backspace");
|
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("27R")}.value !== "HELLO WORLD"`
|
2022-05-03 02:28:00 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("27R"), el => el.value);
|
2022-05-03 02:28:00 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("HELLO WOR");
|
|
|
|
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("27R"), "12.dL", { delay: 200 });
|
2022-05-03 02:28:00 +09:00
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("27R")}.value !== "HELLO WOR"`
|
2022-05-03 02:28:00 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("27R"), el => el.value);
|
2022-05-03 02:28:00 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("HELLO WORDL");
|
|
|
|
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("27R"), " ", { delay: 200 });
|
2022-05-03 02:28:00 +09:00
|
|
|
|
2023-10-27 05:42:41 +09:00
|
|
|
await kbDeleteLastWord(page);
|
2022-05-03 02:28:00 +09:00
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("27R")}.value !== "HELLO WORDL "`
|
2022-05-03 02:28:00 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("27R"), el => el.value);
|
2022-05-03 02:28:00 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("HELLO ");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.$eval(getSelector("27R"), el => {
|
2022-05-03 02:28:00 +09:00
|
|
|
// Select LL
|
|
|
|
el.selectionStart = 2;
|
|
|
|
el.selectionEnd = 4;
|
|
|
|
});
|
|
|
|
|
|
|
|
await page.keyboard.press("a");
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("27R"), el => el.value);
|
2022-05-03 02:28:00 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("HEAO ");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that an infinite loop is not triggered", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.click(getSelector("28R"));
|
|
|
|
await page.$eval(getSelector("28R"), el =>
|
|
|
|
el.setSelectionRange(0, 0)
|
|
|
|
);
|
|
|
|
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("28R"), "Hello", { delay: 200 });
|
2022-05-03 02:28:00 +09:00
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("28R")}.value !== "123"`
|
2022-05-03 02:28:00 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
let text = await page.$eval(getSelector("28R"), el => el.value);
|
2022-05-03 02:28:00 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("Hello123");
|
|
|
|
|
|
|
|
// The action will trigger a calculateNow which itself
|
|
|
|
// will trigger a resetForm (inducing a calculateNow) and a
|
|
|
|
// calculateNow.
|
|
|
|
await page.click("[data-annotation-id='31R']");
|
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("28R")}.value !== "Hello123"`
|
2022-05-03 02:28:00 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
// Without preventing against infinite loop the field is empty.
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("28R"), el => el.value);
|
2022-05-03 02:28:00 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("123");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("in issue14705.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("issue14705.pdf", getSelector("29R"));
|
2022-05-03 02:28:00 +09:00
|
|
|
pages.map(async ([, page]) => {
|
|
|
|
page.on("dialog", async dialog => {
|
|
|
|
await dialog.dismiss();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that field value is correctly updated", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("29R"), "Hello World", { delay: 200 });
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.click(getSelector("27R"));
|
2022-05-03 02:28:00 +09:00
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("29R")}.value !== "Hello World"`
|
2022-05-03 02:28:00 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
let text = await page.$eval(getSelector("29R"), el => el.value);
|
2022-05-03 02:28:00 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("checked");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.click(getSelector("27R"));
|
2022-05-03 02:28:00 +09:00
|
|
|
|
|
|
|
await page.waitForFunction(
|
2022-06-18 05:01:20 +09:00
|
|
|
`${getQuerySelector("29R")}.value !== "checked"`
|
2022-05-03 02:28:00 +09:00
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("29R"), el => el.value);
|
2022-05-03 02:28:00 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("unchecked");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-05-22 21:37:17 +09:00
|
|
|
|
|
|
|
describe("in bug1766987.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("bug1766987.pdf", getSelector("75R"));
|
2022-05-22 21:37:17 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that field value is correctly formatted", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
let text = await page.$eval(getSelector("75R"), el => el.value);
|
2022-05-22 21:37:17 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("150.32 €");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("82R"), el => el.value);
|
2022-05-22 21:37:17 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("12.74 Kwh");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("91R"), el => el.value);
|
2022-05-22 21:37:17 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("352.19 Kwh");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
text = await page.$eval(getSelector("101R"), el => el.value);
|
2022-05-22 21:37:17 +09:00
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("20.57 €");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-06-17 22:20:40 +09:00
|
|
|
|
|
|
|
describe("in issue15053.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2022-06-18 05:01:20 +09:00
|
|
|
pages = await loadAndWait("issue15053.pdf", getSelector("44R"));
|
2022-06-17 22:20:40 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that a button and text field with a border are hidden", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
let visibility = await page.$eval(
|
|
|
|
"[data-annotation-id='35R']",
|
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual("visible");
|
|
|
|
|
|
|
|
visibility = await page.$eval(
|
|
|
|
"[data-annotation-id='51R']",
|
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual("visible");
|
|
|
|
|
2022-06-18 05:01:20 +09:00
|
|
|
await page.click(getSelector("44R"));
|
2023-09-18 02:45:28 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
`document.querySelector("[data-annotation-id='35R']").style.visibility === "hidden"`
|
|
|
|
);
|
2022-06-17 22:20:40 +09:00
|
|
|
|
|
|
|
visibility = await page.$eval(
|
|
|
|
"[data-annotation-id='35R']",
|
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility).withContext(`In ${browserName}`).toEqual("hidden");
|
|
|
|
|
|
|
|
visibility = await page.$eval(
|
|
|
|
"[data-annotation-id='51R']",
|
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility).withContext(`In ${browserName}`).toEqual("hidden");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-06-19 23:39:54 +09:00
|
|
|
|
|
|
|
describe("in bug1675139.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("bug1675139.pdf", getSelector("48R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
2022-06-23 22:47:45 +09:00
|
|
|
it("must check that data-main-rotation is correct", async () => {
|
2022-06-19 23:39:54 +09:00
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
let base = 0;
|
|
|
|
|
|
|
|
while (base !== 360) {
|
|
|
|
for (const [ref, angle] of [
|
|
|
|
[47, 0],
|
|
|
|
[42, 90],
|
|
|
|
[45, 180],
|
|
|
|
[46, 270],
|
|
|
|
]) {
|
2022-10-25 22:28:22 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
(sel, b, a) => {
|
|
|
|
const el = document.querySelector(sel);
|
|
|
|
const rotation =
|
|
|
|
parseInt(el.getAttribute("data-main-rotation")) || 0;
|
|
|
|
return rotation === (360 + ((360 - (b + a)) % 360)) % 360;
|
|
|
|
},
|
|
|
|
{},
|
2022-06-19 23:39:54 +09:00
|
|
|
`[data-annotation-id='${ref}R']`,
|
2022-10-25 22:28:22 +09:00
|
|
|
base,
|
|
|
|
angle
|
2022-06-19 23:39:54 +09:00
|
|
|
);
|
|
|
|
}
|
|
|
|
base += 90;
|
|
|
|
await page.click(getSelector("48R"));
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-06-24 21:23:06 +09:00
|
|
|
|
|
|
|
describe("in issue15092.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("issue15092.pdf", getSelector("39R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that a values is correctly updated on a field and its siblings", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
await clearInput(page, getSelector("39R"));
|
|
|
|
await page.type(getSelector("39R"), "123", { delay: 10 });
|
|
|
|
|
|
|
|
const prevTotal = await page.$eval(
|
|
|
|
getSelector("43R"),
|
|
|
|
el => el.value
|
|
|
|
);
|
|
|
|
|
|
|
|
await clearInput(page, getSelector("42R"));
|
|
|
|
await page.type(getSelector("42R"), "456", { delay: 10 });
|
|
|
|
|
|
|
|
await page.click(getSelector("45R"));
|
|
|
|
|
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("43R")}.value !== "${prevTotal}"`
|
|
|
|
);
|
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("46R")}.value !== "${prevTotal}"`
|
|
|
|
);
|
|
|
|
|
|
|
|
let total = await page.$eval(getSelector("43R"), el => el.value);
|
|
|
|
expect(total).withContext(`In ${browserName}`).toEqual("579.00");
|
|
|
|
|
|
|
|
total = await page.$eval(getSelector("46R"), el => el.value);
|
|
|
|
expect(total).withContext(`In ${browserName}`).toEqual("579.00");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-08-19 02:27:53 +09:00
|
|
|
|
|
|
|
describe("in bug1782564.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("bug1782564.pdf", getSelector("7R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that charLimit is correctly set", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
await clearInput(page, getSelector("7R"));
|
|
|
|
// By default the charLimit is 0 which means that the input
|
|
|
|
// length is unlimited.
|
|
|
|
await page.type(getSelector("7R"), "abcdefghijklmnopq", {
|
|
|
|
delay: 10,
|
|
|
|
});
|
|
|
|
|
|
|
|
let value = await page.$eval(getSelector("7R"), el => el.value);
|
|
|
|
expect(value)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual("abcdefghijklmnopq");
|
|
|
|
|
|
|
|
// charLimit is set to 1
|
|
|
|
await page.click(getSelector("9R"));
|
|
|
|
|
|
|
|
await page.waitForFunction(
|
|
|
|
`document.querySelector('${getSelector(
|
|
|
|
"7R"
|
|
|
|
)}').value !== "abcdefgh"`
|
|
|
|
);
|
|
|
|
|
|
|
|
value = await page.$eval(getSelector("7R"), el => el.value);
|
|
|
|
expect(value).withContext(`In ${browserName}`).toEqual("a");
|
|
|
|
|
|
|
|
await clearInput(page, getSelector("7R"));
|
|
|
|
await page.type(getSelector("7R"), "xyz", { delay: 10 });
|
|
|
|
|
|
|
|
value = await page.$eval(getSelector("7R"), el => el.value);
|
|
|
|
expect(value).withContext(`In ${browserName}`).toEqual("x");
|
|
|
|
|
|
|
|
// charLimit is set to 2
|
|
|
|
await page.click(getSelector("9R"));
|
|
|
|
|
|
|
|
await clearInput(page, getSelector("7R"));
|
|
|
|
await page.type(getSelector("7R"), "xyz", { delay: 10 });
|
|
|
|
|
|
|
|
value = await page.$eval(getSelector("7R"), el => el.value);
|
|
|
|
expect(value).withContext(`In ${browserName}`).toEqual("xy");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-11-28 23:53:17 +09:00
|
|
|
|
|
|
|
describe("in bug1802888.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("bug1802888.pdf", getSelector("30R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check field value is treated by default as a number", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.type(getSelector("30R"), "123", {
|
|
|
|
delay: 10,
|
|
|
|
});
|
|
|
|
await page.click(getSelector("31R"));
|
|
|
|
await page.type(getSelector("31R"), "456", {
|
|
|
|
delay: 10,
|
|
|
|
});
|
|
|
|
await page.click(getSelector("26R"));
|
|
|
|
await page.click(getSelector("27R"));
|
|
|
|
await page.waitForFunction(`${getQuerySelector("26R")}.value !== ""`);
|
|
|
|
|
|
|
|
const value = await page.$eval(getSelector("26R"), el => el.value);
|
|
|
|
expect(value).withContext(`In ${browserName}`).toEqual("579");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-11-30 00:37:02 +09:00
|
|
|
|
|
|
|
describe("in issue15753.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("issue15753.pdf", getSelector("27R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check field value is correctly updated when committed with ENTER key", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.type(getSelector("27R"), "abc", {
|
|
|
|
delay: 10,
|
|
|
|
});
|
|
|
|
await page.keyboard.press("Enter");
|
|
|
|
await page.waitForFunction(`${getQuerySelector("28R")}.value !== ""`);
|
|
|
|
let value = await page.$eval(getSelector("28R"), el => el.value);
|
|
|
|
expect(value).withContext(`In ${browserName}`).toEqual("abc");
|
|
|
|
|
|
|
|
await page.type(getSelector("27R"), "def", {
|
|
|
|
delay: 10,
|
|
|
|
});
|
|
|
|
|
|
|
|
await page.keyboard.press("Enter");
|
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("28R")}.value !== "abc"`
|
|
|
|
);
|
|
|
|
value = await page.$eval(getSelector("28R"), el => el.value);
|
|
|
|
expect(value).withContext(`In ${browserName}`).toEqual("abcdef");
|
|
|
|
|
2023-10-27 05:42:41 +09:00
|
|
|
await kbSelectAll(page);
|
2022-11-30 00:37:02 +09:00
|
|
|
await page.keyboard.press("Backspace");
|
|
|
|
|
|
|
|
await page.keyboard.press("Enter");
|
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("28R")}.value !== "abcdef"`
|
|
|
|
);
|
|
|
|
value = await page.$eval(getSelector("28R"), el => el.value);
|
|
|
|
expect(value).withContext(`In ${browserName}`).toEqual("");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-12-13 08:07:45 +09:00
|
|
|
|
|
|
|
describe("in issue15815.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("issue15815.pdf", getSelector("24R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check field value is correctly updated when committed with ENTER key", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
let value = "A";
|
|
|
|
for (const [displayValue, exportValue] of [
|
|
|
|
["B", "x2"],
|
|
|
|
["C", "x3"],
|
|
|
|
["A", "x1"],
|
|
|
|
]) {
|
|
|
|
await clearInput(page, getSelector("27R"));
|
|
|
|
await page.select(getSelector("24R"), exportValue);
|
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("27R")}.value !== ""`
|
|
|
|
);
|
|
|
|
const text = await page.$eval(getSelector("27R"), el => el.value);
|
|
|
|
expect(text)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(`value=${value}, changeEx=${exportValue}`);
|
|
|
|
value = displayValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const exportValue of ["x3", "x2", "x1"]) {
|
|
|
|
await clearInput(page, getSelector("27R"));
|
|
|
|
await page.type(getSelector("27R"), exportValue);
|
|
|
|
await page.click("[data-annotation-id='28R']");
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
value = await page.$eval(getSelector("24R"), el => el.value);
|
|
|
|
expect(value).withContext(`In ${browserName}`).toEqual(exportValue);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-12-14 00:08:36 +09:00
|
|
|
|
|
|
|
describe("in issue15818.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("issue15818.pdf", getSelector("27R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check the field value set when the document is open", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.waitForFunction(`${getQuerySelector("27R")}.value !== ""`);
|
|
|
|
|
|
|
|
const text = await page.$eval(getSelector("27R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("hello world");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check the format action is called when setFocus is used", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
Use realistic typing delays for the scripting integration tests
In the scripting integration tests we use a few different typing
delays, mostly 100 or 200 milliseconds. According to for example
https://www.typingpal.com/en/documentation/school-edition/pedagogical-resources/typing-speed,
a fast typing speed is around 300 characters per minute, which is 5
characters per second and therefore a delay of 200 milliseconds between
each keystroke. Note that this is already above average, so in practice
the delay will be even larger. Therefore the 100 milliseconds variant
is unrealistically fast and therefore not suitable for the integration
tests which aim to simulate the average user behavior.
On top of that, the quick typing speeds are problematic for the tests
that involve validation alert dialogs appearing during typing. In those
tests a handler is registered to close the dialog once it pops up, but
it takes time for Puppeteer to notice the dialog, trigger the handler
and close it. If the typing delay, which is the delay between the key
down and key up events according to the Puppeteer source code at
https://github.com/puppeteer/puppeteer/blob/master/packages/puppeteer-core/src/cdp/Input.ts#L209-L215,
is too short, the key up event will be fired before the dialog is
closed. In that time the text box we're typing in is not focused, so
when the dialog is closed the `page.type()` call on the text box will
never resolve because the key up event never reached the text box.
This commit aims to fix the issues by converting all 100 millisecond
delays to 200 milliseconds. For instance the "must check input for US
zip format" failed pretty consistently locally before and hasn't failed
anymore with a 200 millisecond delay.
2023-09-24 22:29:12 +09:00
|
|
|
await page.type(getSelector("30R"), "abc", { delay: 200 });
|
2022-12-14 00:08:36 +09:00
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("30R")}.value !== "abc"`
|
|
|
|
);
|
2023-04-25 18:35:21 +09:00
|
|
|
await page.waitForTimeout(100);
|
2022-12-14 00:08:36 +09:00
|
|
|
|
|
|
|
const focusedId = await page.evaluate(_ =>
|
|
|
|
window.document.activeElement.getAttribute("data-element-id")
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(focusedId).withContext(`In ${browserName}`).toEqual("31R");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-01-05 03:49:31 +09:00
|
|
|
|
|
|
|
describe("in autoprint.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2023-10-08 02:20:06 +09:00
|
|
|
// Autoprinting is triggered by the `Open` event, which is one of the
|
|
|
|
// first events to be dispatched to the sandbox, even before scripting
|
|
|
|
// is reported to be ready. It's therefore important that `loadAndWait`
|
|
|
|
// returns control as soon as possible after opening the PDF document,
|
|
|
|
// and the first element we can check for is the `<html>` tag of the
|
|
|
|
// viewer. Note that the `autoprint.pdf` file is very small, so printing
|
|
|
|
// it is usually very fast and therefore activating the selector check
|
|
|
|
// too late will cause it to never resolve because printing is already
|
|
|
|
// done (and the printed page div removed) before we even get to it.
|
|
|
|
pages = await loadAndWait("autoprint.pdf", "html");
|
2023-01-05 03:49:31 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check if printing is triggered when the document is open", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
2023-09-24 19:38:00 +09:00
|
|
|
await page.waitForSelector(".printedPage");
|
2023-01-05 03:49:31 +09:00
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-01-26 21:04:48 +09:00
|
|
|
|
|
|
|
describe("in bug1811694.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("bug1811694.pdf", getSelector("25R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that a field value with a number isn't changed", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.click(getSelector("25R"));
|
|
|
|
await page.type(getSelector("25R"), "00000000123", { delay: 10 });
|
|
|
|
|
|
|
|
let text = await page.$eval(getSelector("25R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("00000000123");
|
|
|
|
|
|
|
|
await page.click(getSelector("26R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
text = await page.$eval(getSelector("25R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("00000000123");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("in bug1811510.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("bug1811510.pdf", getSelector("22R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that a field value with a number with a comma has the correct value", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
let text = await page.$eval(getSelector("22R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("5,25");
|
|
|
|
|
|
|
|
await page.$eval(getSelector("31R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("5,25");
|
|
|
|
|
|
|
|
await page.click(getSelector("22R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
text = await page.$eval(getSelector("22R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("5,25");
|
|
|
|
|
|
|
|
await page.click(getSelector("31R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
text = await page.$eval(getSelector("31R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("5.25");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-02-20 00:33:05 +09:00
|
|
|
|
|
|
|
describe("in issue16067.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("issue16067.pdf", getSelector("6R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that a field has the correct value when a choice is changed", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
let text = await page.$eval(getSelector("44R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("");
|
|
|
|
|
|
|
|
await page.select(getSelector("6R"), "Yes");
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
text = await page.$eval(getSelector("44R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("Yes");
|
|
|
|
|
|
|
|
await clearInput(page, getSelector("44R"));
|
|
|
|
|
|
|
|
await page.select(getSelector("6R"), "No");
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
text = await page.$eval(getSelector("44R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("No");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-05-17 06:03:01 +09:00
|
|
|
|
|
|
|
describe("in bug1825002.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("bug1825002.pdf", getSelector("23R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that a field has the correct formatted value", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
let text = await page.$eval(getSelector("23R"), el => el.value);
|
|
|
|
expect(text)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual("ABCDEFGHIJKLMN");
|
|
|
|
|
|
|
|
await page.click(getSelector("23R"));
|
|
|
|
await page.waitForFunction(
|
|
|
|
`${getQuerySelector("23R")}.value !== "ABCDEFGHIJKLMN"`
|
|
|
|
);
|
|
|
|
|
|
|
|
text = await page.$eval(getSelector("23R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("123,45.7A");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that a field is empty", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
let text = await page.$eval(getSelector("26R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("");
|
|
|
|
|
|
|
|
await page.click(getSelector("26R"));
|
|
|
|
await page.type(getSelector("26R"), "abcde", { delay: 10 });
|
|
|
|
|
|
|
|
await page.click(getSelector("23R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
await page.click(getSelector("26R"));
|
|
|
|
|
2023-10-27 05:42:41 +09:00
|
|
|
await kbSelectAll(page);
|
2023-05-17 06:03:01 +09:00
|
|
|
await page.keyboard.press("Backspace");
|
|
|
|
|
|
|
|
await page.click(getSelector("23R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
text = await page.$eval(getSelector("26R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-07-21 16:49:11 +09:00
|
|
|
|
|
|
|
describe("in bug1844576.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("bug1844576.pdf", getSelector("9R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that a field has the correct formatted value", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
2023-09-17 19:55:13 +09:00
|
|
|
const hasVisibleCanvas = await page.$eval(
|
|
|
|
`[data-annotation-id="9R"] > canvas`,
|
|
|
|
elem => elem && !elem.hasAttribute("hidden")
|
|
|
|
);
|
2023-07-21 16:49:11 +09:00
|
|
|
expect(hasVisibleCanvas)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(true);
|
|
|
|
|
2023-09-17 19:55:13 +09:00
|
|
|
const hasHiddenInput = await page.$eval(
|
|
|
|
`[data-annotation-id="9R"] > input`,
|
|
|
|
elem => elem?.hasAttribute("hidden")
|
|
|
|
);
|
2023-07-21 16:49:11 +09:00
|
|
|
expect(hasHiddenInput).withContext(`In ${browserName}`).toEqual(true);
|
|
|
|
|
|
|
|
await page.click(getSelector("12R"));
|
2023-09-17 19:59:56 +09:00
|
|
|
await page.waitForSelector(
|
|
|
|
`[data-annotation-id="9R"] > canvas[hidden]`
|
|
|
|
);
|
2023-07-21 16:49:11 +09:00
|
|
|
|
2023-09-17 19:55:13 +09:00
|
|
|
const hasHiddenCanvas = await page.$eval(
|
|
|
|
`[data-annotation-id="9R"] > canvas`,
|
|
|
|
elem => elem?.hasAttribute("hidden")
|
|
|
|
);
|
2023-07-21 16:49:11 +09:00
|
|
|
expect(hasHiddenCanvas)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(true);
|
|
|
|
|
2023-09-17 19:55:13 +09:00
|
|
|
const hasVisibleInput = await page.$eval(
|
|
|
|
`[data-annotation-id="9R"] > input`,
|
|
|
|
elem => elem && !elem.hasAttribute("hidden")
|
|
|
|
);
|
2023-07-21 16:49:11 +09:00
|
|
|
expect(hasVisibleInput)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual(true);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-07-30 22:52:27 +09:00
|
|
|
|
|
|
|
describe("in annotation_hidden_noview.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait(
|
|
|
|
"annotation_hidden_noview.pdf",
|
|
|
|
getSelector("11R")
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that invisible fields are made visible", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
let visibility = await page.$eval(
|
|
|
|
getSelector("7R"),
|
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility).withContext(`In ${browserName}`).toEqual("hidden");
|
|
|
|
|
|
|
|
visibility = await page.$eval(
|
|
|
|
getSelector("8R"),
|
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility).withContext(`In ${browserName}`).toEqual("hidden");
|
|
|
|
|
|
|
|
await page.click(getSelector("11R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
visibility = await page.$eval(
|
|
|
|
getSelector("7R"),
|
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual("visible");
|
|
|
|
|
|
|
|
visibility = await page.$eval(
|
|
|
|
getSelector("8R"),
|
|
|
|
el => getComputedStyle(el).visibility
|
|
|
|
);
|
|
|
|
expect(visibility)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual("visible");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-08-24 05:00:52 +09:00
|
|
|
|
|
|
|
describe("in issue16863.pdf", () => {
|
|
|
|
let pages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
pages = await loadAndWait("issue16863.pdf", getSelector("334R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that checkboxes are correctly resetted", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page]) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
let readonly = await page.$eval(
|
|
|
|
getSelector("353R"),
|
|
|
|
el => el.disabled
|
|
|
|
);
|
|
|
|
expect(readonly).withContext(`In ${browserName}`).toEqual(true);
|
|
|
|
await page.click(getSelector("334R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
readonly = await page.$eval(getSelector("353R"), el => el.disabled);
|
|
|
|
expect(readonly).withContext(`In ${browserName}`).toEqual(true);
|
|
|
|
await page.click(getSelector("351R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
readonly = await page.$eval(getSelector("353R"), el => el.disabled);
|
|
|
|
expect(readonly).withContext(`In ${browserName}`).toEqual(true);
|
|
|
|
await page.click(getSelector("352R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
readonly = await page.$eval(getSelector("353R"), el => el.disabled);
|
|
|
|
expect(readonly).withContext(`In ${browserName}`).toEqual(false);
|
|
|
|
|
|
|
|
await page.click(getSelector("353R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
let checked = await page.$eval(getSelector("353R"), el => el.checked);
|
|
|
|
expect(checked).withContext(`In ${browserName}`).toEqual(true);
|
|
|
|
await page.click(getSelector("334R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
readonly = await page.$eval(getSelector("353R"), el => el.disabled);
|
|
|
|
expect(readonly).withContext(`In ${browserName}`).toEqual(true);
|
|
|
|
checked = await page.$eval(getSelector("353R"), el => el.checked);
|
|
|
|
expect(checked).withContext(`In ${browserName}`).toEqual(false);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-09-05 21:15:01 +09:00
|
|
|
|
|
|
|
describe("Textfields and focus", () => {
|
|
|
|
let pages;
|
|
|
|
let otherPages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
otherPages = await Promise.all(
|
|
|
|
global.integrationSessions.map(async session =>
|
|
|
|
session.browser.newPage()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
pages = await loadAndWait("evaljs.pdf", getSelector("55R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
await Promise.all(otherPages.map(page => page.close()));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that focus/blur callbacks aren't called", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page], i) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.click(getSelector("55R"));
|
|
|
|
await page.type(getSelector("55R"), "Hello", { delay: 10 });
|
|
|
|
await page.click(getSelector("56R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
await page.click(getSelector("55R"));
|
|
|
|
await page.type(getSelector("55R"), " World", { delay: 10 });
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
|
|
|
|
await otherPages[i].bringToFront();
|
|
|
|
await otherPages[i].waitForTimeout(100);
|
|
|
|
await page.bringToFront();
|
|
|
|
await page.waitForTimeout(100);
|
|
|
|
|
|
|
|
const text = await page.$eval(getSelector("55R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("Hello World");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-11-09 21:50:33 +09:00
|
|
|
|
|
|
|
describe("Textfield with a Blur callback", () => {
|
|
|
|
let pages;
|
|
|
|
let otherPages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
otherPages = await Promise.all(
|
|
|
|
global.integrationSessions.map(async session =>
|
|
|
|
session.browser.newPage()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
pages = await loadAndWait("bug1863910.pdf", getSelector("25R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
await Promise.all(otherPages.map(page => page.close()));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that blur callback is called", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page], i) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.click(getSelector("25R"));
|
|
|
|
await page.waitForTimeout(10);
|
|
|
|
await page.click(getSelector("26R"));
|
|
|
|
|
|
|
|
await page.waitForFunction(
|
|
|
|
sel => document.querySelector(sel).value !== "",
|
|
|
|
{},
|
|
|
|
getSelector("26R")
|
|
|
|
);
|
|
|
|
|
|
|
|
const text = await page.$eval(getSelector("26R"), el => el.value);
|
|
|
|
expect(text).withContext(`In ${browserName}`).toEqual("hello");
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-11-13 19:05:03 +09:00
|
|
|
|
|
|
|
describe("Radio button without T value", () => {
|
|
|
|
let pages;
|
|
|
|
let otherPages;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
otherPages = await Promise.all(
|
|
|
|
global.integrationSessions.map(async session =>
|
|
|
|
session.browser.newPage()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
pages = await loadAndWait("bug1860602.pdf", getSelector("22R"));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await closePages(pages);
|
|
|
|
await Promise.all(otherPages.map(page => page.close()));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("must check that only one radio is selected", async () => {
|
|
|
|
await Promise.all(
|
|
|
|
pages.map(async ([browserName, page], i) => {
|
|
|
|
await page.waitForFunction(
|
|
|
|
"window.PDFViewerApplication.scriptingReady === true"
|
|
|
|
);
|
|
|
|
await scrollIntoView(page, getSelector("22R"));
|
|
|
|
|
|
|
|
await page.click(getSelector("25R"));
|
|
|
|
await waitForEntryInStorage(page, "25R", { value: true });
|
|
|
|
|
|
|
|
let storage = await getAnnotationStorage(page);
|
|
|
|
expect(storage)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual({
|
|
|
|
"25R": { value: true },
|
|
|
|
"28R": { value: false },
|
2023-11-23 04:23:52 +09:00
|
|
|
"35R": { value: false },
|
|
|
|
"38R": { value: false },
|
|
|
|
"41R": { value: false },
|
|
|
|
"44R": { value: false },
|
|
|
|
"47R": { value: false },
|
|
|
|
"50R": { value: false },
|
|
|
|
"22R": { value: false },
|
2023-11-13 19:05:03 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
await page.click(getSelector("22R"));
|
|
|
|
await waitForEntryInStorage(page, "22R", { value: true });
|
|
|
|
|
|
|
|
storage = await getAnnotationStorage(page);
|
|
|
|
expect(storage)
|
|
|
|
.withContext(`In ${browserName}`)
|
|
|
|
.toEqual({
|
|
|
|
"25R": { value: false },
|
|
|
|
"28R": { value: false },
|
2023-11-23 04:23:52 +09:00
|
|
|
"35R": { value: false },
|
|
|
|
"38R": { value: false },
|
|
|
|
"41R": { value: false },
|
|
|
|
"44R": { value: false },
|
|
|
|
"47R": { value: false },
|
|
|
|
"50R": { value: false },
|
|
|
|
"22R": { value: true },
|
2023-11-13 19:05:03 +09:00
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2020-12-01 02:11:28 +09:00
|
|
|
});
|