diff --git a/test/integration/freetext_editor_spec.mjs b/test/integration/freetext_editor_spec.mjs index c7aa0e3c4e9391..98d91eac1c5b77 100644 --- a/test/integration/freetext_editor_spec.mjs +++ b/test/integration/freetext_editor_spec.mjs @@ -2354,14 +2354,14 @@ describe("FreeText Editor", () => { `${getEditorSelector(1)} .overlay.enabled` ); - rect = await page.$eval(getEditorSelector(0), el => { + rect = await page.$eval(getEditorSelector(1), el => { const { x, y, width, height } = el.getBoundingClientRect(); return { x, y, width, height }; }); await page.mouse.click( - rect.x + 5 * rect.width, - rect.y + 5 * rect.height + rect.x + 0.5 * rect.width, + rect.y + 0.5 * rect.height ); await waitForSelectedEditor(page, getEditorSelector(1)); diff --git a/test/integration/scripting_spec.mjs b/test/integration/scripting_spec.mjs index a17b2ef00c029c..e235ebdb11ff85 100644 --- a/test/integration/scripting_spec.mjs +++ b/test/integration/scripting_spec.mjs @@ -17,6 +17,7 @@ import { awaitPromise, clearInput, closePages, + closeSinglePage, getAnnotationStorage, getComputedStyleSelector, getFirstSerialized, @@ -418,41 +419,37 @@ describe("Interaction", () => { pages = await loadAndWait("doc_actions.pdf", getSelector("47R")); }); - 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") { - pending("Disabled in Firefox on Windows, because of bug 1662471."); - } - await page.waitForFunction( - "window.PDFViewerApplication.scriptingReady === true" - ); - - await clearInput(page, getSelector("47R")); - await page.evaluate(_ => { - window.document.activeElement.blur(); - }); - await page.waitForFunction(`${getQuerySelector("47R")}.value === ""`); + // Run the tests sequentially to avoid to use the same printer at the same + // time. + // And to make sure that a printer isn't locked by a process we close the + // page before running the next test. + for (const [browserName, page] of pages) { + await page.waitForFunction( + "window.PDFViewerApplication.scriptingReady === true" + ); - let text = await actAndWaitForInput( - page, - getSelector("47R"), - async () => { - await page.click("#print"); - } - ); - expect(text).withContext(`In ${browserName}`).toEqual("WillPrint"); + await clearInput(page, getSelector("47R")); + await page.evaluate(_ => { + window.document.activeElement.blur(); + }); + await page.waitForFunction(`${getQuerySelector("47R")}.value === ""`); - await page.waitForFunction(`${getQuerySelector("50R")}.value !== ""`); + const text = await actAndWaitForInput( + page, + getSelector("47R"), + async () => { + await page.click("#print"); + } + ); + expect(text).withContext(`In ${browserName}`).toEqual("WillPrint"); + await page.keyboard.press("Escape"); - text = await page.$eval(getSelector("50R"), el => el.value); - expect(text).withContext(`In ${browserName}`).toEqual("DidPrint"); - }) - ); + await page.waitForFunction( + `${getQuerySelector("50R")}.value === "DidPrint"` + ); + await closeSinglePage(page); + } }); }); @@ -1792,6 +1789,9 @@ describe("Interaction", () => { "", null /* pageSetup = */, async page => { + page.on("dialog", async dialog => { + await dialog.dismiss(); + }); printHandles.set( page, await page.evaluateHandle(() => [ @@ -1825,11 +1825,9 @@ describe("Interaction", () => { }); it("must check if printing is triggered when the document is open", async () => { - await Promise.all( - pages.map(async ([browserName, page]) => { - await awaitPromise(printHandles.get(page)); - }) - ); + for (const [, page] of pages) { + await awaitPromise(printHandles.get(page)); + } }); }); diff --git a/test/integration/test_utils.mjs b/test/integration/test_utils.mjs index 18d8b9540abf4d..0ad91c780b5d80 100644 --- a/test/integration/test_utils.mjs +++ b/test/integration/test_utils.mjs @@ -76,13 +76,13 @@ function awaitPromise(promise) { } function closePages(pages) { - return Promise.all( - pages.map(async ([_, page]) => { - // Avoid to keep something from a previous test. - await page.evaluate(() => window.localStorage.clear()); - await page.close({ runBeforeUnload: false }); - }) - ); + return Promise.all(pages.map(async ([_, page]) => closeSinglePage(page))); +} + +async function closeSinglePage(page) { + // Avoid to keep something from a previous test. + await page.evaluate(() => window.localStorage.clear()); + await page.close({ runBeforeUnload: false }); } async function waitForSandboxTrip(page) { @@ -557,6 +557,7 @@ export { awaitPromise, clearInput, closePages, + closeSinglePage, createPromise, dragAndDropAnnotation, firstPageOnTop, diff --git a/test/test.mjs b/test/test.mjs index 6fad013ac32ee7..7c959443b476ca 100644 --- a/test/test.mjs +++ b/test/test.mjs @@ -878,7 +878,7 @@ function unitTestPostHandler(req, res) { async function startBrowser({ browserName, headless, startUrl }) { const options = { product: browserName, - protocol: "cdp", + protocol: "webDriverBiDi", headless, defaultViewport: null, ignoreDefaultArgs: ["--disable-extensions"], @@ -905,10 +905,6 @@ async function startBrowser({ browserName, headless, startUrl }) { } if (browserName === "firefox") { - // Run tests with the WebDriver BiDi protocol enabled only for Firefox for - // now given that for Chrome further fixes are needed first. - options.protocol = "webDriverBiDi"; - options.extraPrefsFirefox = { // avoid to have a prompt when leaving a page with a form "dom.disable_beforeunload": true,