Rename force_document_end to needs_document_end_workaround

This commit is contained in:
Florian Bruhin 2019-02-25 09:57:17 +01:00
parent 94542c5f78
commit 184e0ee44e
4 changed files with 6 additions and 6 deletions

View File

@ -117,7 +117,7 @@ class GreasemonkeyScript:
script.includes = ['*']
return script
def force_document_end(self):
def needs_document_end_workaround(self):
"""Check whether to force @run-at document-end.
This needs to be done on QtWebEngine with Qt 5.12 for known-broken

View File

@ -1042,7 +1042,7 @@ class _WebEngineScripts(QObject):
# Override the @run-at value parsed by QWebEngineScript if desired.
if injection_point:
new_script.setInjectionPoint(injection_point)
elif script.force_document_end():
elif script.needs_document_end_workaround():
log.greasemonkey.debug("Forcing @run-at document-end for {}"
.format(script.name))
new_script.setInjectionPoint(QWebEngineScript.DocumentReady)

View File

@ -94,8 +94,8 @@ class TestWebengineScripts:
collection = webengine_scripts._widget.page().scripts()
assert collection.toList()[-1].worldId() == worldid
def test_greasemonkey_force_document_end(self, monkeypatch,
webengine_scripts):
def test_greasemonkey_document_end_workaround(self, monkeypatch,
webengine_scripts):
"""Make sure document-end is forced when needed."""
monkeypatch.setattr(greasemonkey.objects, 'backend',
usertypes.Backend.QtWebEngine)

View File

@ -201,7 +201,7 @@ class TestForceDocumentEnd:
patch(backend=backend, qt_512=qt_512)
script = self._get_script(namespace='https://github.com/ParticleCore',
name='Iridium')
assert not script.force_document_end()
assert not script.needs_document_end_workaround()
@pytest.mark.parametrize('namespace, name, force', [
('http://userstyles.org', 'foobar', True),
@ -213,7 +213,7 @@ class TestForceDocumentEnd:
"""Test matching based on namespace/name."""
patch(backend=usertypes.Backend.QtWebEngine, qt_512=True)
script = self._get_script(namespace=namespace, name=name)
assert script.force_document_end() == force
assert script.needs_document_end_workaround() == force
def test_required_scripts_are_included(download_stub, tmpdir):