[Bug]: Firefox fires `cancel` on a file input before `change` when a FileChooser's `setFiles` is called (1.65.0)

Aperta
#43,994 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
playwright, typescript
Ambito
testing-qa

Direzione di ricerca

Start by tracing how Firefox handles FileChooser.setFiles and dispatches file input events; the issue provides a JavaScript reproduction but names no source files or tests. Run the reproduction against Firefox and confirm the current event order. Done when cancel no longer fires before input and change for a programmatic file selection, while genuine cancellation behavior remains correct.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version

1.65.0 (Firefox 159.0, revision 1572). Not in 1.64.1 (revision 1555).

Steps to reproduce
import { firefox } from 'playwright';

const browser = await firefox.launch();
const page = await browser.newPage();
page.on('console', (m) => console.log(m.text()));
await page.setContent(`<button onclick="
	const i = document.createElement('input'); i.type = 'file';
	for (const e of ['cancel', 'input', 'change']) i.addEventListener(e, () => console.log(e, i.files.length));
	i.click();">open</button>`);
const [chooser] = await Promise.all([page.waitForEvent('filechooser'), page.click('button')]);
await chooser.setFiles('some-file.txt');
await page.waitForTimeout(1000);
await browser.close();
Expected behavior

As with 1.64.1, and with Chromium in 1.65.0:

input 1
change 1
Actual behavior
cancel 0
input 1
change 1

cancel arrives about 60 ms before input and change, with no files. Code that resolves a promise on the first of change and cancel takes the choice as cancelled. That's a common pattern for a file input that isn't attached to the document.

Additional context

A user choosing a file in Firefox gets no cancel, and the HTML spec fires cancel only when the selection is cancelled or unchanged. We pinned 1.64.1 for now.

Environment

macOS (arm64), Node.js 24.16.0, also on GitHub's macOS runners.

Lingua principale
TypeScript
Stelle
99.1k
Fork
6.8k
Merge medio
16h 56m
PR unite (30g)
299

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright

Tutte le issue di microsoft/playwright

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.