Merge branch 'log-javascript-console' of https://github.com/flv0/qutebrowser into flv0-log-javascript-console

This commit is contained in:
Florian Bruhin 2015-11-30 08:08:31 +01:00
commit 5f13fd2ece
5 changed files with 28 additions and 14 deletions

View File

@ -503,8 +503,15 @@ class BrowserPage(QWebPage):
def javaScriptConsoleMessage(self, msg, line, source):
"""Override javaScriptConsoleMessage to use debug log."""
if config.get('general', 'log-javascript-console'):
log.js.debug("[{}:{}] {}".format(source, line, msg))
log_javascript_console = config.get('general',
'log-javascript-console')
logstring = "[{}:{}] {}".format(source, line, msg)
logmap = {
'debug': log.js.debug,
'info': log.js.info,
'none': lambda arg: None
}
logmap[log_javascript_console](logstring)
def chooseFile(self, _frame, suggested_file):
"""Override QWebPage's chooseFile to be able to chose a file to upload.

View File

@ -356,7 +356,9 @@ class ConfigManager(QObject):
('tabs', 'position'): _transform_position,
('ui', 'downloads-position'): _transform_position,
('ui', 'remove-finished-downloads'):
_get_value_transformer({'false': '-1', 'true': '1000'})
_get_value_transformer({'false': '-1', 'true': '1000'}),
('general', 'log-javascript-console'):
_get_value_transformer({'false': 'none', 'true': 'debug'}),
}
changed = pyqtSignal(str, str)

View File

@ -229,8 +229,13 @@ def data(readonly=False):
"launched."),
('log-javascript-console',
SettingValue(typ.Bool(), 'false'),
"Whether to log javascript console messages."),
SettingValue(typ.String(
valid_values=typ.ValidValues(
('none', "Don't log messages."),
('debug', "Log messages with debug level."),
('info', "Log messages with info level.")
)), 'debug'),
"How to log javascript console messages."),
('save-session',
SettingValue(typ.Bool(), 'false'),

View File

@ -67,7 +67,7 @@ Feature: Keyboard input
Scenario: Forwarding all keys
When I open data/keyinput/log.html
And I set general -> log-javascript-console to true
And I set general -> log-javascript-console to info
And I set input -> forward-unbound-keys to all
And I press the key "q"
And I press the key "<F1>"
@ -80,7 +80,7 @@ Feature: Keyboard input
Scenario: Forwarding special keys
When I open data/keyinput/log.html
And I set general -> log-javascript-console to true
And I set general -> log-javascript-console to info
And I set input -> forward-unbound-keys to auto
And I press the key "x"
And I press the key "<F1>"
@ -93,7 +93,7 @@ Feature: Keyboard input
Scenario: Forwarding no keys
When I open data/keyinput/log.html
And I set general -> log-javascript-console to true
And I set general -> log-javascript-console to info
And I set input -> forward-unbound-keys to none
And I press the key "<F1>"
# <F1>
@ -107,7 +107,7 @@ Feature: Keyboard input
Then the error "Could not parse 'blub': Got unknown key." should be shown
Scenario: :fake-key sending key to the website
When I set general -> log-javascript-console to true
When I set general -> log-javascript-console to info
And I open data/keyinput/log.html
And I run :fake-key x
Then the javascript message "key press: 88" should be logged
@ -125,14 +125,14 @@ Feature: Keyboard input
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
When I set general -> log-javascript-console to info
And I open data/keyinput/log.html
And I run :fake-key <Escape>
Then the javascript message "key press: 27" should be logged
And the javascript message "key release: 27" should be logged
Scenario: :fake-key sending keychain to the website
When I set general -> log-javascript-console to true
When I set general -> log-javascript-console to info
And I open data/keyinput/log.html
And I run :fake-key xy
Then the javascript message "key press: 88" should be logged

View File

@ -50,19 +50,19 @@ Feature: Various utility commands.
## :jseval
Scenario: :jseval
When I set general -> log-javascript-console to true
When I set general -> log-javascript-console to info
And I run :jseval console.log("Hello from JS!");
And I wait for "[:0] Hello from JS!" in the log
Then the message "No output or error" should be shown
Scenario: :jseval without logging
When I set general -> log-javascript-console to false
When I set general -> log-javascript-console to none
And I run :jseval console.log("Hello from JS!");
Then the message "No output or error" should be shown
And "[:0] Hello from JS!" should not be logged
Scenario: :jseval with --quiet
When I set general -> log-javascript-console to true
When I set general -> log-javascript-console to info
And I run :jseval --quiet console.log("Hello from JS!");
And I wait for "[:0] Hello from JS!" in the log
Then "No output or error" should not be logged