Merge branch 'flv0-log-javascript-console'
This commit is contained in:
commit
455e5f6523
@ -20,7 +20,7 @@
|
||||
|<<general-site-specific-quirks,site-specific-quirks>>|Enable workarounds for broken sites.
|
||||
|<<general-default-encoding,default-encoding>>|Default encoding to use for websites.
|
||||
|<<general-new-instance-open-target,new-instance-open-target>>|How to open links in an existing instance if a new one is launched.
|
||||
|<<general-log-javascript-console,log-javascript-console>>|Whether to log javascript console messages.
|
||||
|<<general-log-javascript-console,log-javascript-console>>|How to log javascript console messages.
|
||||
|<<general-save-session,save-session>>|Whether to always save the open pages.
|
||||
|<<general-session-default-name,session-default-name>>|The name of the session to save by default, or empty for the last loaded session.
|
||||
|<<general-url-incdec-segments,url-incdec-segments>>|The URL segments where `:navigate increment/decrement` will search for a number.
|
||||
@ -439,14 +439,15 @@ Default: +pass:[tab]+
|
||||
|
||||
[[general-log-javascript-console]]
|
||||
=== log-javascript-console
|
||||
Whether to log javascript console messages.
|
||||
How to log javascript console messages.
|
||||
|
||||
Valid values:
|
||||
|
||||
* +true+
|
||||
* +false+
|
||||
* +none+: Don't log messages.
|
||||
* +debug+: Log messages with debug level.
|
||||
* +info+: Log messages with info level.
|
||||
|
||||
Default: +pass:[false]+
|
||||
Default: +pass:[debug]+
|
||||
|
||||
[[general-save-session]]
|
||||
=== save-session
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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'),
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user