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 = ['*'] script.includes = ['*']
return script return script
def force_document_end(self): def needs_document_end_workaround(self):
"""Check whether to force @run-at document-end. """Check whether to force @run-at document-end.
This needs to be done on QtWebEngine with Qt 5.12 for known-broken 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. # Override the @run-at value parsed by QWebEngineScript if desired.
if injection_point: if injection_point:
new_script.setInjectionPoint(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 {}" log.greasemonkey.debug("Forcing @run-at document-end for {}"
.format(script.name)) .format(script.name))
new_script.setInjectionPoint(QWebEngineScript.DocumentReady) new_script.setInjectionPoint(QWebEngineScript.DocumentReady)

View File

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

View File

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