Add --quiet argument to :jseval.

This commit is contained in:
Florian Bruhin 2015-06-12 11:24:04 +02:00
parent 8ecc3a3bb0
commit efcea65596
2 changed files with 10 additions and 3 deletions

View File

@ -244,12 +244,15 @@ Toggle the web inspector.
[[jseval]]
=== jseval
Syntax: +:jseval 'js_code'+
Syntax: +:jseval [*--quiet*] 'js-code'+
Evaluate a JavaScript string.
==== positional arguments
* +'js_code'+: The string to evaluate.
* +'js-code'+: The string to evaluate.
==== optional arguments
* +*-q*+, +*--quiet*+: Don't show resulting JS object.
==== note
* This command does not split arguments after the last argument and handles quotes literally.

View File

@ -1566,15 +1566,19 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window',
maxsplit=0, no_cmd_split=True)
def jseval(self, js_code):
def jseval(self, js_code, quiet=False):
"""Evaluate a JavaScript string.
Args:
js_code: The string to evaluate.
quiet: Don't show resulting JS object.
"""
frame = self._current_widget().page().mainFrame()
out = frame.evaluateJavaScript(js_code)
if quiet:
return
if out is None:
# Getting the actual error (if any) seems to be difficult. The
# error does end up in BrowserPage.javaScriptConsoleMessage(), but