Issue 40291635

Support <input type=file capture> on desktop crbug.com/40291635

Overview

The HTML Media Capture spec defines a capture attribute on file inputs that should open the device camera/mic instead of a file picker. This works on Android but not on desktop.

Expected: Clicking the file button on inputs with capture opens Chrome's camera/mic capture dialog.

Broken: The capture attribute is ignored and the normal OS file picker opens.

JS Feature Detection: HTMLInputElement.prototype.capture is ...

Tests

Test 1: Image capture (user-facing)

Should open camera
<input type="file" accept="image/*" capture="user">

Opens front camera to take a photo.

Waiting...

Test 2: Image capture (environment)

Should open camera
<input type="file" accept="image/*" capture="environment">

Opens rear camera to take a photo.

Waiting...

Test 3: Video capture

Should record video
<input type="file" accept="video/*" capture="user">

Opens camera + mic to record a video clip.

Waiting...

Test 4: Audio capture

Should record audio
<input type="file" accept="audio/*" capture="user">

Opens microphone to record audio.

Waiting...

Test 5: Boolean capture

Should open camera
<input type="file" accept="image/*" capture>

The bare capture attribute (no value) should also trigger the dialog.

Waiting...

Test 6: Control (no capture)

Normal file picker
<input type="file" accept="image/*">

Without capture, the normal OS file picker should open.

Waiting...

Test 7: Legacy 2010 syntax

Should open camera
<input type="file" accept="image/*;capture=camera">

The original 2010 spec put capture inside accept. Some sites still use this.

Waiting...

Spec References

Modern: W3C HTML Media Capture (current)

Legacy: W3C HTML Media Capture (2010 WD)

How to Verify

1. Build Chromium with the patch applied.

2. Open this page in the patched build.

3. Click the file button on Tests 1-5. Each should open Chrome's capture dialog.

4. After capturing, click Check Submission to verify the form has a valid attachment.

5. Test 6 (control) should still open the normal file picker.

6. JS feature detection above should show supported.