From 922fdc05266433284bd77d09f15b1bd6b409b69f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 24 Nov 2015 16:28:56 +0100 Subject: [PATCH] Fix :fake-key with no focused webview. --- qutebrowser/browser/commands.py | 2 +- tests/integration/features/misc.feature | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 8456fd132..420f4fe62 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1779,7 +1779,7 @@ class CommandDispatcher: try: receiver = objreg.get('webview', scope='tab', tab='current') - except KeyError: + except objreg.RegistryUnavailableError: raise cmdexc.CommandError("No focused webview!") QApplication.postEvent(receiver, press_event) diff --git a/tests/integration/features/misc.feature b/tests/integration/features/misc.feature index 5da8d1a40..ed34fe71b 100644 --- a/tests/integration/features/misc.feature +++ b/tests/integration/features/misc.feature @@ -130,6 +130,17 @@ Feature: Various utility commands. Then the javascript message "key press: 88" should be logged And the javascript message "key release: 88" should be logged + @not_xvfb + Scenario: :fake-key sending key to the website with other window focused + When I open data/misc/fakekey.html + And I set general -> developer-extras to true + And I run :inspector + And I wait for "Focus object changed: " in the log + And I run :fake-key x + And I run :inspector + And I wait for "Focus object changed: " in the log + Then the error "No focused webview!" should be shown. + Scenario: :fake-key sending special key to the website When I set general -> log-javascript-console to true And I open data/misc/fakekey.html