WebEngine: Disable createWindow for Qt < 5.7.1
Fixes #1911. The bugfix is backported in my qt5-webengine-debug package, and QUTE_QTBUG54419_PATCHED can be set to force qutebrowser to use createWindow.
This commit is contained in:
parent
6a26907ded
commit
cf070d48f2
@ -18,6 +18,7 @@ markers =
|
|||||||
qtwebengine_todo: Features still missing with QtWebEngine
|
qtwebengine_todo: Features still missing with QtWebEngine
|
||||||
qtwebengine_skip: Tests not applicable with QtWebEngine
|
qtwebengine_skip: Tests not applicable with QtWebEngine
|
||||||
qtwebkit_skip: Tests not applicable with QtWebKit
|
qtwebkit_skip: Tests not applicable with QtWebKit
|
||||||
|
qtwebengine_createWindow: Tests using createWindow with QtWebEngine (QTBUG-54419)
|
||||||
qt_log_level_fail = WARNING
|
qt_log_level_fail = WARNING
|
||||||
qt_log_ignore =
|
qt_log_ignore =
|
||||||
^SpellCheck: .*
|
^SpellCheck: .*
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
"""The main browser widget for QtWebEngine."""
|
"""The main browser widget for QtWebEngine."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, QUrl
|
from PyQt5.QtCore import pyqtSignal, QUrl
|
||||||
# pylint: disable=no-name-in-module,import-error,useless-suppression
|
# pylint: disable=no-name-in-module,import-error,useless-suppression
|
||||||
@ -26,7 +27,7 @@ from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
|
|||||||
# pylint: enable=no-name-in-module,import-error,useless-suppression
|
# pylint: enable=no-name-in-module,import-error,useless-suppression
|
||||||
|
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
from qutebrowser.utils import log, debug, usertypes, objreg
|
from qutebrowser.utils import log, debug, usertypes, objreg, qtutils, message
|
||||||
|
|
||||||
|
|
||||||
class WebEngineView(QWebEngineView):
|
class WebEngineView(QWebEngineView):
|
||||||
@ -63,6 +64,16 @@ class WebEngineView(QWebEngineView):
|
|||||||
Return:
|
Return:
|
||||||
The new QWebEngineView object.
|
The new QWebEngineView object.
|
||||||
"""
|
"""
|
||||||
|
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-54419
|
||||||
|
vercheck = qtutils.version_check
|
||||||
|
qtbug_54419_fixed = ((vercheck('5.6.2') and not vercheck('5.7.0')) or
|
||||||
|
qtutils.version_check('5.7.1') or
|
||||||
|
os.environ.get('QUTE_QTBUG54419_PATCHED', ''))
|
||||||
|
if not qtbug_54419_fixed:
|
||||||
|
message.error(self._win_id, "Qt 5.6.2/5.7.1 or newer is required "
|
||||||
|
"to open new tabs via JS!")
|
||||||
|
return None
|
||||||
|
|
||||||
debug_type = debug.qenum_key(QWebEnginePage, wintype)
|
debug_type = debug.qenum_key(QWebEnginePage, wintype)
|
||||||
log.webview.debug("createWindow with type {}".format(debug_type))
|
log.webview.debug("createWindow with type {}".format(debug_type))
|
||||||
background = False
|
background = False
|
||||||
|
@ -99,7 +99,7 @@ def get_fatal_crash_dialog(debug, data):
|
|||||||
def _get_environment_vars():
|
def _get_environment_vars():
|
||||||
"""Gather environment variables for the crash info."""
|
"""Gather environment variables for the crash info."""
|
||||||
masks = ('DESKTOP_SESSION', 'DE', 'QT_*', 'PYTHON*', 'LC_*', 'LANG',
|
masks = ('DESKTOP_SESSION', 'DE', 'QT_*', 'PYTHON*', 'LC_*', 'LANG',
|
||||||
'XDG_*')
|
'XDG_*', 'QUTE_*')
|
||||||
info = []
|
info = []
|
||||||
for key, value in os.environ.items():
|
for key, value in os.environ.items():
|
||||||
for m in masks:
|
for m in masks:
|
||||||
|
@ -132,6 +132,10 @@ if not getattr(sys, 'frozen', False):
|
|||||||
def pytest_collection_modifyitems(config, items):
|
def pytest_collection_modifyitems(config, items):
|
||||||
"""Apply @qtwebengine_* markers."""
|
"""Apply @qtwebengine_* markers."""
|
||||||
webengine = config.getoption('--qute-bdd-webengine')
|
webengine = config.getoption('--qute-bdd-webengine')
|
||||||
|
vercheck = qtutils.version_check
|
||||||
|
qtbug_54419_fixed = ((vercheck('5.6.2') and not vercheck('5.7.0')) or
|
||||||
|
qtutils.version_check('5.7.1') or
|
||||||
|
os.environ.get('QUTE_QTBUG54419_PATCHED', ''))
|
||||||
|
|
||||||
markers = {
|
markers = {
|
||||||
'qtwebengine_todo': ('QtWebEngine TODO', pytest.mark.xfail, webengine),
|
'qtwebengine_todo': ('QtWebEngine TODO', pytest.mark.xfail, webengine),
|
||||||
@ -139,6 +143,8 @@ def pytest_collection_modifyitems(config, items):
|
|||||||
webengine),
|
webengine),
|
||||||
'qtwebkit_skip': ('Skipped with QtWebKit', pytest.mark.skipif,
|
'qtwebkit_skip': ('Skipped with QtWebKit', pytest.mark.skipif,
|
||||||
not webengine),
|
not webengine),
|
||||||
|
'qtwebengine_createWindow': ('Skipped because of QTBUG-54419',
|
||||||
|
pytest.mark.skipif, not qtbug_54419_fixed)
|
||||||
}
|
}
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
|
@ -19,6 +19,7 @@ Feature: Using hints
|
|||||||
|
|
||||||
### Opening in current or new tab
|
### Opening in current or new tab
|
||||||
|
|
||||||
|
@qtwebengine_createWindow
|
||||||
Scenario: Following a hint and force to open in current tab.
|
Scenario: Following a hint and force to open in current tab.
|
||||||
When I open data/hints/link_blank.html
|
When I open data/hints/link_blank.html
|
||||||
And I hint with args "links current" and follow a
|
And I hint with args "links current" and follow a
|
||||||
@ -26,6 +27,7 @@ Feature: Using hints
|
|||||||
Then the following tabs should be open:
|
Then the following tabs should be open:
|
||||||
- data/hello.txt (active)
|
- data/hello.txt (active)
|
||||||
|
|
||||||
|
@qtwebengine_createWindow
|
||||||
Scenario: Following a hint and allow to open in new tab.
|
Scenario: Following a hint and allow to open in new tab.
|
||||||
When I open data/hints/link_blank.html
|
When I open data/hints/link_blank.html
|
||||||
And I hint with args "links normal" and follow a
|
And I hint with args "links normal" and follow a
|
||||||
@ -34,6 +36,7 @@ Feature: Using hints
|
|||||||
- data/hints/link_blank.html
|
- data/hints/link_blank.html
|
||||||
- data/hello.txt (active)
|
- data/hello.txt (active)
|
||||||
|
|
||||||
|
@qtwebengine_createWindow
|
||||||
Scenario: Following a hint to link with sub-element and force to open in current tab.
|
Scenario: Following a hint to link with sub-element and force to open in current tab.
|
||||||
When I open data/hints/link_span.html
|
When I open data/hints/link_span.html
|
||||||
And I run :tab-close
|
And I run :tab-close
|
||||||
@ -151,11 +154,13 @@ Feature: Using hints
|
|||||||
And I hint wht args "links normal" and follow a
|
And I hint wht args "links normal" and follow a
|
||||||
Then "navigation request: url http://localhost:*/data/hello2.txt, type NavigationTypeLinkClicked, *" should be logged
|
Then "navigation request: url http://localhost:*/data/hello2.txt, type NavigationTypeLinkClicked, *" should be logged
|
||||||
|
|
||||||
|
@qtwebengine_createWindow
|
||||||
Scenario: Opening a link inside a specific iframe
|
Scenario: Opening a link inside a specific iframe
|
||||||
When I open data/hints/iframe_target.html
|
When I open data/hints/iframe_target.html
|
||||||
And I hint with args "links normal" and follow a
|
And I hint with args "links normal" and follow a
|
||||||
Then "navigation request: url http://localhost:*/data/hello.txt, type NavigationTypeLinkClicked, *" should be logged
|
Then "navigation request: url http://localhost:*/data/hello.txt, type NavigationTypeLinkClicked, *" should be logged
|
||||||
|
|
||||||
|
@qtwebengine_createWindow
|
||||||
Scenario: Opening a link with specific target frame in a new tab
|
Scenario: Opening a link with specific target frame in a new tab
|
||||||
When I open data/hints/iframe_target.html
|
When I open data/hints/iframe_target.html
|
||||||
And I hint with args "links tab" and follow a
|
And I hint with args "links tab" and follow a
|
||||||
|
@ -20,6 +20,7 @@ Feature: Javascript stuff
|
|||||||
Then "Requested to close * which does not exist!" should be logged
|
Then "Requested to close * which does not exist!" should be logged
|
||||||
|
|
||||||
@qtwebkit_skip
|
@qtwebkit_skip
|
||||||
|
@qtwebengine_createWindow
|
||||||
Scenario: Closing a JS window twice (issue 906) - qtwebengine
|
Scenario: Closing a JS window twice (issue 906) - qtwebengine
|
||||||
When I open about:blank
|
When I open about:blank
|
||||||
And I open data/javascript/issue906.html in a new tab
|
And I open data/javascript/issue906.html in a new tab
|
||||||
|
@ -551,6 +551,7 @@ Feature: Various utility commands.
|
|||||||
Then the page should not be scrolled
|
Then the page should not be scrolled
|
||||||
And the error "prompt-accept: This command is only allowed in prompt/yesno mode." should be shown
|
And the error "prompt-accept: This command is only allowed in prompt/yesno mode." should be shown
|
||||||
|
|
||||||
|
@qtwebengine_createWindow
|
||||||
Scenario: :repeat-command with mode-switching command
|
Scenario: :repeat-command with mode-switching command
|
||||||
Given I open data/hints/link_blank.html
|
Given I open data/hints/link_blank.html
|
||||||
And I run :tab-only
|
And I run :tab-only
|
||||||
|
@ -76,6 +76,7 @@ def test_parse_fatal_stacktrace(text, typ, func):
|
|||||||
"QT_IM_MODULE = fcitx"
|
"QT_IM_MODULE = fcitx"
|
||||||
),
|
),
|
||||||
({'LANGUAGE': 'foo', 'LANG': 'en_US.UTF-8'}, "LANG = en_US.UTF-8"),
|
({'LANGUAGE': 'foo', 'LANG': 'en_US.UTF-8'}, "LANG = en_US.UTF-8"),
|
||||||
|
({'FOO': 'bar', 'QUTE_BLAH': '1'}, "QUTE_BLAH = 1"),
|
||||||
], ids=lambda e: e[1])
|
], ids=lambda e: e[1])
|
||||||
def test_get_environment_vars(monkeypatch, env, expected):
|
def test_get_environment_vars(monkeypatch, env, expected):
|
||||||
"""Test for crashdialog._get_environment_vars."""
|
"""Test for crashdialog._get_environment_vars."""
|
||||||
|
2
tox.ini
2
tox.ini
@ -13,7 +13,7 @@ skipsdist = true
|
|||||||
setenv =
|
setenv =
|
||||||
QT_QPA_PLATFORM_PLUGIN_PATH={envdir}/Lib/site-packages/PyQt5/plugins/platforms
|
QT_QPA_PLATFORM_PLUGIN_PATH={envdir}/Lib/site-packages/PyQt5/plugins/platforms
|
||||||
PYTEST_QT_API=pyqt5
|
PYTEST_QT_API=pyqt5
|
||||||
passenv = PYTHON DISPLAY XAUTHORITY HOME USERNAME USER CI TRAVIS XDG_*
|
passenv = PYTHON DISPLAY XAUTHORITY HOME USERNAME USER CI TRAVIS XDG_* QUTE_*
|
||||||
deps =
|
deps =
|
||||||
-r{toxinidir}/misc/requirements/requirements-pip.txt
|
-r{toxinidir}/misc/requirements/requirements-pip.txt
|
||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
|
Loading…
Reference in New Issue
Block a user