javascript.assemble: Support document module
This commit is contained in:
parent
2c6fe35398
commit
afc7faabda
@ -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)
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user