1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Isolate the scripting integration tests

To avoid being able to introduce dependencies between tests, and to
bring existing dependencies to the surface, this commit makes sure that
we close the document between tests so that we can't accidentally rely
on state set by a previous test. This prevents multiple tests from
failing if one of them fails and makes debugging easier by being able to
run each test on their own independent of other tests.

This commit, combined with the previous ones, is enough to make the
scripting integration test suite pass consistently if random mode in
Jasmine is enabled, proving that the tests are fully isolated now.
This commit is contained in:
Tim van der Meij 2025-03-16 20:08:56 +01:00
parent 0f3692a621
commit 1c73e526e0
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762

View file

@ -74,11 +74,11 @@ describe("Interaction", () => {
describe("in 160F-2019.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("160F-2019.pdf", getSelector("416R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -291,11 +291,11 @@ describe("Interaction", () => {
describe("in js-buttons.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("js-buttons.pdf", getSelector("80R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -418,7 +418,7 @@ describe("Interaction", () => {
describe("in doc_actions.pdf for printing", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("doc_actions.pdf", getSelector("47R"), null, {
earlySetup: () => {
// No need to trigger the print dialog.
@ -459,11 +459,11 @@ describe("Interaction", () => {
describe("in doc_actions.pdf for saving", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("doc_actions.pdf", getSelector("47R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -506,11 +506,11 @@ describe("Interaction", () => {
describe("in doc_actions.pdf for page actions", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("doc_actions.pdf", getSelector("47R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -563,11 +563,11 @@ describe("Interaction", () => {
describe("in js-authors.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("js-authors.pdf", getSelector("25R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -594,11 +594,11 @@ describe("Interaction", () => {
describe("in listbox_actions.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("listbox_actions.pdf", getSelector("33R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -736,11 +736,11 @@ describe("Interaction", () => {
describe("in js-colors.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("js-colors.pdf", getSelector("34R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -809,11 +809,11 @@ describe("Interaction", () => {
describe("in issue13132.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue13132.pdf", getSelector("171R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -868,11 +868,11 @@ describe("Interaction", () => {
describe("Check field properties", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("evaljs.pdf", getSelector("55R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -943,11 +943,11 @@ describe("Interaction", () => {
describe("in issue13269.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue13269.pdf", getSelector("27R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -978,13 +978,14 @@ describe("Interaction", () => {
describe("in secHandler.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("secHandler.pdf", getSelector("25R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
it("must print securityHandler value in a text field", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
@ -1006,7 +1007,7 @@ describe("Interaction", () => {
describe("in issue14307.pdf (1)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue14307.pdf", getSelector("30R"));
pages.map(async ([, page]) => {
page.on("dialog", async dialog => {
@ -1015,7 +1016,7 @@ describe("Interaction", () => {
});
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1049,7 +1050,7 @@ describe("Interaction", () => {
describe("in issue14307.pdf (2)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue14307.pdf", getSelector("30R"));
pages.map(async ([, page]) => {
page.on("dialog", async dialog => {
@ -1058,7 +1059,7 @@ describe("Interaction", () => {
});
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1094,7 +1095,7 @@ describe("Interaction", () => {
describe("in issue14307.pdf (3)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue14307.pdf", getSelector("30R"));
pages.map(async ([, page]) => {
page.on("dialog", async dialog => {
@ -1103,7 +1104,7 @@ describe("Interaction", () => {
});
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1139,7 +1140,7 @@ describe("Interaction", () => {
describe("in issue14862.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue14862.pdf", getSelector("27R"));
pages.map(async ([, page]) => {
page.on("dialog", async dialog => {
@ -1148,7 +1149,7 @@ describe("Interaction", () => {
});
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1234,7 +1235,7 @@ describe("Interaction", () => {
describe("in issue14705.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue14705.pdf", getSelector("29R"));
pages.map(async ([, page]) => {
page.on("dialog", async dialog => {
@ -1243,7 +1244,7 @@ describe("Interaction", () => {
});
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1278,11 +1279,11 @@ describe("Interaction", () => {
describe("in bug1766987.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1766987.pdf", getSelector("75R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1310,11 +1311,11 @@ describe("Interaction", () => {
describe("in issue15053.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue15053.pdf", getSelector("44R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1363,11 +1364,11 @@ describe("Interaction", () => {
describe("in bug1675139.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1675139.pdf", getSelector("48R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1409,11 +1410,11 @@ describe("Interaction", () => {
describe("in issue15092.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue15092.pdf", getSelector("39R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1444,11 +1445,11 @@ describe("Interaction", () => {
describe("in bug1782564.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1782564.pdf", getSelector("7R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1489,11 +1490,11 @@ describe("Interaction", () => {
describe("in bug1802888.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1802888.pdf", getSelector("30R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1519,11 +1520,11 @@ describe("Interaction", () => {
describe("in issue15753.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue15753.pdf", getSelector("27R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1564,11 +1565,11 @@ describe("Interaction", () => {
describe("in issue15815.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue15815.pdf", getSelector("24R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1611,11 +1612,11 @@ describe("Interaction", () => {
describe("in issue15818.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue15818.pdf", getSelector("27R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1658,7 +1659,7 @@ describe("Interaction", () => {
describe("in autoprint.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
// 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`
@ -1687,7 +1688,7 @@ describe("Interaction", () => {
});
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1709,11 +1710,11 @@ describe("Interaction", () => {
describe("in bug1811694.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1811694.pdf", getSelector("25R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1741,11 +1742,11 @@ describe("Interaction", () => {
describe("in bug1811510.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1811510.pdf", getSelector("22R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1781,11 +1782,11 @@ describe("Interaction", () => {
describe("in issue16067.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue16067.pdf", getSelector("6R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1816,11 +1817,11 @@ describe("Interaction", () => {
describe("in bug1825002.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1825002.pdf", getSelector("23R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1870,11 +1871,11 @@ describe("Interaction", () => {
describe("in bug1844576.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1844576.pdf", getSelector("9R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1925,14 +1926,14 @@ describe("Interaction", () => {
describe("in annotation_hidden_noview.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait(
"annotation_hidden_noview.pdf",
getSelector("11R")
);
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -1984,11 +1985,11 @@ describe("Interaction", () => {
describe("in issue16863.pdf", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue16863.pdf", getSelector("334R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2048,7 +2049,7 @@ describe("Interaction", () => {
let pages;
let otherPages;
beforeAll(async () => {
beforeEach(async () => {
otherPages = await Promise.all(
global.integrationSessions.map(async session =>
session.browser.newPage()
@ -2057,7 +2058,7 @@ describe("Interaction", () => {
pages = await loadAndWait("evaljs.pdf", getSelector("55R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
await Promise.all(otherPages.map(page => page.close()));
});
@ -2091,11 +2092,11 @@ describe("Interaction", () => {
describe("Textfield with a Blur callback", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1863910.pdf", getSelector("25R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2123,11 +2124,11 @@ describe("Interaction", () => {
describe("Radio button without T value", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1860602.pdf", getSelector("22R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2180,11 +2181,11 @@ describe("Interaction", () => {
describe("Textfield with a number and some decimals", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue17540.pdf", getSelector("15R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2213,11 +2214,11 @@ describe("Interaction", () => {
describe("Textfield with a zip code starting with 0", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1889122.pdf", getSelector("24R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2241,11 +2242,11 @@ describe("Interaction", () => {
describe("Value of event.change when a choice list is modified", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue17998.pdf", getSelector("7R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2275,11 +2276,11 @@ describe("Interaction", () => {
describe("PageOpen and PageClose actions in fields", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue18305.pdf", getSelector("7R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2320,11 +2321,11 @@ describe("Interaction", () => {
describe("Compute product of different fields", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue18536.pdf", getSelector("34R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2357,11 +2358,11 @@ describe("Interaction", () => {
describe("Calculate field value even if one callback throws", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue18561.pdf", getSelector("24R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2385,11 +2386,11 @@ describe("Interaction", () => {
describe("Correctly format numbers", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1918115.pdf", getSelector("33R"));
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2413,11 +2414,11 @@ describe("Interaction", () => {
describe("Change radio property", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1922766.pdf", "[data-annotation-id='44R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2456,11 +2457,11 @@ describe("Interaction", () => {
describe("Date creation must be timezone consistent", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("bug1934157.pdf", "[data-annotation-id='24R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});
@ -2494,11 +2495,11 @@ describe("Interaction", () => {
describe("Skip throwing actions (issue 19505)", () => {
let pages;
beforeAll(async () => {
beforeEach(async () => {
pages = await loadAndWait("issue19505.pdf", "[data-annotation-id='24R']");
});
afterAll(async () => {
afterEach(async () => {
await closePages(pages);
});