From 1647c28632823c8bf23585433507eed66a6aa6e3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 8 Sep 2018 16:20:38 +0200 Subject: [PATCH] Allow lists for javascript.convert_js_arg --- qutebrowser/utils/javascript.py | 2 ++ tests/unit/utils/test_javascript.py | 1 + 2 files changed, 3 insertions(+) diff --git a/qutebrowser/utils/javascript.py b/qutebrowser/utils/javascript.py index 93df8e70f..21b373dd1 100644 --- a/qutebrowser/utils/javascript.py +++ b/qutebrowser/utils/javascript.py @@ -59,6 +59,8 @@ def _convert_js_arg(arg): return str(arg).lower() elif isinstance(arg, (int, float)): return str(arg) + elif isinstance(arg, list): + return '[{}]'.format(', '.join(_convert_js_arg(e) for e in arg)) else: raise TypeError("Don't know how to handle {!r} of type {}!".format( arg, type(arg).__name__)) diff --git a/tests/unit/utils/test_javascript.py b/tests/unit/utils/test_javascript.py index 29e090fd0..0a196cfa1 100644 --- a/tests/unit/utils/test_javascript.py +++ b/tests/unit/utils/test_javascript.py @@ -84,6 +84,7 @@ class TestStringEscape: (None, 'undefined'), (object(), TypeError), (True, 'true'), + ([23, True, 'x'], '[23, true, "x"]'), ]) def test_convert_js_arg(arg, expected): if expected is TypeError: