Skip to content

[Bug]: Integration tests with copyImage timeout in Firefox in headless mode #20918

Closed

Description

@Aditi-1400

Attach (recommended) or Link to PDF file

The issue is related to Integration test failures

Web browser and its version

firefox@nightly_150.0a1

Operating system and its version

macOS Tahoe Version 26.3.1

PDF.js version

v5.5.207

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No

Steps to reproduce the problem

When running the integration tests locally in the headless mode on Firefox, all the integration tests using copyImage timeout with:

Error: Waiting for selector pdfjs_internal_editor_${N} canvas failed

I have a small reproduction for this:

import puppeteer from "puppeteer";
import fs from "fs";

const pngBase64 = fs.readFileSync("image.png").toString("base64");

const browser = await puppeteer.launch({
  headless: false,
  browser: "chrome",
});

const page = await browser.newPage();
await page.goto("https://example.com");

await page.evaluate(async (pngBase64) => {
  const res = await fetch(`data:image/png;base64,${pngBase64}`);
  const blob = await res.blob();
  await navigator.clipboard.write([new ClipboardItem({ "image/png": blob })]);
}, pngBase64);
console.log("write: ok");

await page.evaluate(() => document.body.contentEditable = "true");
await page.click("body");
const modifier = process.platform === "darwin" ? "Meta" : "Control";
await page.keyboard.down(modifier);
await page.keyboard.press("v");
await page.keyboard.up(modifier);

try {
  await page.waitForSelector("img", { timeout: 20000 });
  console.log("paste: ok");
} catch {
  console.log("paste: FAILED");
}

await browser.close();

What is the expected behavior?

The tests should not timeout.

What went wrong?

When using Puppeteer with Firefox in headless mode, navigator.clipboard.write([new ClipboardItem({ "image/png": blob })]) succeeds without error, but subsequent keyboard paste (Ctrl/Cmd+V) fails to insert the image. The same code works correctly in Chrome (headless or not) and in Firefox non-headless mode.

We should either disable these tests for Firefox in the headless mode or use #stampEditorFileInput to add the image instead, except when testing the copy/paste functionality itself.

Link to a viewer

No response

Additional context

No response

Activity

  1. timvandermeij commented on Mar 19, 2026

    @timvandermeij
    Collaborator

    I ran into this in the initial version of #20371 too (which is #20029), and found out that this is bug in Firefox specifically. It's tracked in https://bugzilla.mozilla.org/show_bug.cgi?id=1878643 upstream, and eventually decided that for the short term only running the integration tests in headful mode is feasible because this might take some time to get fixed. I believe it's also not the only problem in headless mode, but it is the most prominent one at least, and it would be nice to strive for being able to run the integration tests successfully in both modes because ideally there should not be any difference.

  2. timvandermeij commented on Sep 20, 2026

    @timvandermeij
    Collaborator

    Closing since the upstream bug is fixed. I have confirmed that most stamp editor integration tests, that invoke copyImage, now pass in Firefox headless mode. The other issues that prevent us from actually using headless mode in general for the integration tests are now tracked in #21991.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions