diff --git a/qutebrowser/browser/shared.py b/qutebrowser/browser/shared.py index 8ce9c136e..28830a5d4 100644 --- a/qutebrowser/browser/shared.py +++ b/qutebrowser/browser/shared.py @@ -434,5 +434,8 @@ def _execute_fileselect_command( if not qb_mode == FileSelectionMode.multiple_files: if len(selected_files) > 1: message.warning("More than one file/folder chosen, using only the first") - return selected_files[:1] + selected_files = selected_files[:1] + for selected_file in selected_files: + if not os.path.exists(selected_file): + message.warning(f"Selected non-existent file '{selected_file}'") return selected_files diff --git a/tests/end2end/features/editor.feature b/tests/end2end/features/editor.feature index 9f82766fb..c18ae8038 100644 --- a/tests/end2end/features/editor.feature +++ b/tests/end2end/features/editor.feature @@ -240,6 +240,16 @@ Feature: Opening external editors And the error "Failed to open tempfile *" should be shown And "Failed to delete tempfile *" should be logged with level error + ## Select non-existent file + + Scenario: Select non-existent file + When I set fileselect.handler to external + When I setup a fake single_file fileselector selecting "tests/end2end/data/numbers/non-existent.txt" and writes to a temporary file + And I open data/fileselect.html + And I run :click-element id single_file + Then the javascript message "Files: non-existent.txt" should not be logged + And the warning "Selected non-existent file *tests/end2end/data/numbers/non-existent.txt'" should be shown + ## Select folder @qtwebkit_skip