mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 07:08:08 +02:00
Fix the "must convert input to uppercase" scripting integration test
This integration test fails intermittently because we're not (correctly) awaiting the sandbox actions. The `27R` field in `issue14862.pdf` triggers sandbox events for every typing action, but for the backspace and "a" character typing actions we weren't awaiting the sandbox trip at all, and for other places we weren't awaiting it fully (causing some characters to be missed in the assertion). This commit fixes the issues by using the appropriate helper functions, similar to what we did in PR #18399. Not only is this shorter in terms of code, but it also fixed the near-permafail for this test with newer versions of Puppeteer.
This commit is contained in:
parent
20fbb4d661
commit
3adf8b6be0
1 changed files with 12 additions and 28 deletions
|
@ -1229,59 +1229,43 @@ describe("Interaction", () => {
|
||||||
|
|
||||||
await typeAndWaitForSandbox(page, getSelector("27R"), "Hello");
|
await typeAndWaitForSandbox(page, getSelector("27R"), "Hello");
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
`${getQuerySelector("27R")}.value !== "Hello"`
|
`${getQuerySelector("27R")}.value === "HELLO"`
|
||||||
);
|
);
|
||||||
|
|
||||||
let text = await page.$eval(getSelector("27R"), el => el.value);
|
|
||||||
expect(text).withContext(`In ${browserName}`).toEqual("HELLO");
|
|
||||||
|
|
||||||
await typeAndWaitForSandbox(page, getSelector("27R"), " world");
|
await typeAndWaitForSandbox(page, getSelector("27R"), " world");
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
`${getQuerySelector("27R")}.value !== "HELLO world"`
|
`${getQuerySelector("27R")}.value === "HELLO WORLD"`
|
||||||
);
|
);
|
||||||
|
|
||||||
text = await page.$eval(getSelector("27R"), el => el.value);
|
|
||||||
expect(text).withContext(`In ${browserName}`).toEqual("HELLO WORLD");
|
|
||||||
|
|
||||||
await page.keyboard.press("Backspace");
|
await page.keyboard.press("Backspace");
|
||||||
|
await waitForSandboxTrip(page);
|
||||||
await page.keyboard.press("Backspace");
|
await page.keyboard.press("Backspace");
|
||||||
|
await waitForSandboxTrip(page);
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
`${getQuerySelector("27R")}.value !== "HELLO WORLD"`
|
`${getQuerySelector("27R")}.value === "HELLO WOR"`
|
||||||
);
|
);
|
||||||
|
|
||||||
text = await page.$eval(getSelector("27R"), el => el.value);
|
|
||||||
expect(text).withContext(`In ${browserName}`).toEqual("HELLO WOR");
|
|
||||||
|
|
||||||
await typeAndWaitForSandbox(page, getSelector("27R"), "12.dL");
|
await typeAndWaitForSandbox(page, getSelector("27R"), "12.dL");
|
||||||
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
`${getQuerySelector("27R")}.value !== "HELLO WOR"`
|
`${getQuerySelector("27R")}.value === "HELLO WORDL"`
|
||||||
);
|
);
|
||||||
|
|
||||||
text = await page.$eval(getSelector("27R"), el => el.value);
|
|
||||||
expect(text).withContext(`In ${browserName}`).toEqual("HELLO WORDL");
|
|
||||||
|
|
||||||
await typeAndWaitForSandbox(page, getSelector("27R"), " ");
|
await typeAndWaitForSandbox(page, getSelector("27R"), " ");
|
||||||
|
|
||||||
await kbDeleteLastWord(page);
|
await kbDeleteLastWord(page);
|
||||||
|
await waitForSandboxTrip(page);
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
`${getQuerySelector("27R")}.value !== "HELLO WORDL "`
|
`${getQuerySelector("27R")}.value === "HELLO "`
|
||||||
);
|
);
|
||||||
|
|
||||||
text = await page.$eval(getSelector("27R"), el => el.value);
|
|
||||||
expect(text).withContext(`In ${browserName}`).toEqual("HELLO ");
|
|
||||||
|
|
||||||
await page.$eval(getSelector("27R"), el => {
|
await page.$eval(getSelector("27R"), el => {
|
||||||
// Select LL
|
// Select LL
|
||||||
el.selectionStart = 2;
|
el.selectionStart = 2;
|
||||||
el.selectionEnd = 4;
|
el.selectionEnd = 4;
|
||||||
});
|
});
|
||||||
|
await typeAndWaitForSandbox(page, getSelector("27R"), "a");
|
||||||
await page.keyboard.press("a");
|
await page.waitForFunction(
|
||||||
text = await page.$eval(getSelector("27R"), el => el.value);
|
`${getQuerySelector("27R")}.value === "HEAO "`
|
||||||
expect(text).withContext(`In ${browserName}`).toEqual("HEAO ");
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue