tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit a8a62bb8a67d2053f0125ee18ed7d35ac9554f6b
parent 69a33a86baa14949ce76f6ef5c82988a7f375052
Author: Kagami Sascha Rosylight <krosylight@proton.me>
Date:   Mon, 13 Oct 2025 20:33:14 +0000

Bug 1975933 - Ask and show camera/microphone picker when accept attribute is empty r=android-reviewers,nalexander

This aligns with Chrome behavior.

Note that the behavior is still different when accept/capture attribute exists:

1. Firefox has been and will still be showing camera/microphone if accept attribute exists, while Chrome decides not to. I'm keeping the current behavior, because the media picker does not allow camera and I don't see why that's good for users.
2. Firefox is ignoring capture attribute if accept attribute has wildcard in subtype (`image/*`), while Chrome does not. I think we should follow Chrome but in a separate patch.

Differential Revision: https://phabricator.services.mozilla.com/D266053

Diffstat:
Mmobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/file/MimeType.kt | 2+-
Mmobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/file/FilePickerTest.kt | 3++-
Mmobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/file/MimeTypeTest.kt | 2+-
3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/mobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/file/MimeType.kt b/mobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/file/MimeType.kt @@ -138,7 +138,7 @@ internal sealed class MimeType( * there will not be a match. */ open fun matches(mimeTypes: Array<out String>) = - mimeTypes.isNotEmpty() && mimeTypes.any { it.startsWith(type) } + mimeTypes.isEmpty() || mimeTypes.any { it.startsWith(type) } open fun shouldCapture(mimeTypes: Array<out String>, capture: File.FacingMode) = capture != File.FacingMode.NONE && diff --git a/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/file/FilePickerTest.kt b/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/file/FilePickerTest.kt @@ -57,7 +57,8 @@ class FilePickerTest { private val noopSingle: (Context, Uri) -> Unit = { _, _ -> } private val noopMulti: (Context, Array<Uri>) -> Unit = { _, _ -> } private val request = PromptRequest.File( - mimeTypes = emptyArray(), + // Explicitly request non-media file + mimeTypes = arrayOf("application/json"), onSingleFileSelected = noopSingle, onMultipleFilesSelected = noopMulti, onDismiss = {}, diff --git a/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/file/MimeTypeTest.kt b/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/file/MimeTypeTest.kt @@ -64,7 +64,7 @@ class MimeTypeTest { @Test fun `matches empty list of mime types`() { - assertTypes(setOf(MimeType.Wildcard)) { + assertTypes(setOf(MimeType.Image(), MimeType.Audio, MimeType.Video, MimeType.Wildcard)) { it.matches(emptyArray()) } }