From afc7faabdacda2bb89854d455dcf83e203a7851b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 18 Aug 2016 14:07:21 +0200 Subject: [PATCH] javascript.assemble: Support document module --- qutebrowser/utils/javascript.py | 4 ++-- tests/unit/utils/test_javascript.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/qutebrowser/utils/javascript.py b/qutebrowser/utils/javascript.py index 4fc7e546c..9eef12e72 100644 --- a/qutebrowser/utils/javascript.py +++ b/qutebrowser/utils/javascript.py @@ -64,8 +64,8 @@ def _convert_js_arg(arg): def assemble(module, function, *args): """Assemble a javascript file and a function call.""" js_args = ', '.join(_convert_js_arg(arg) for arg in args) - if module == 'window': - parts = ['window', function] + if module in ['window', 'document']: + parts = [module, function] else: parts = ['window', '_qutebrowser', module, function] code = '"use strict";\n{}({});'.format('.'.join(parts), js_args) diff --git a/tests/unit/utils/test_javascript.py b/tests/unit/utils/test_javascript.py index 298a75312..f379322e8 100644 --- a/tests/unit/utils/test_javascript.py +++ b/tests/unit/utils/test_javascript.py @@ -142,6 +142,7 @@ def test_convert_js_arg(arg, expected): @pytest.mark.parametrize('base, expected_base', [ ('window', 'window'), + ('document', 'document'), ('foo', 'window._qutebrowser.foo'), ]) def test_assemble(base, expected_base):