javascript.assemble: Support document module

This commit is contained in:
Florian Bruhin 2016-08-18 14:07:21 +02:00
parent 2c6fe35398
commit afc7faabda
2 changed files with 3 additions and 2 deletions

View File

@ -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)

View File

@ -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):