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:
Florian Bruhin 2016-09-05 12:16:58 +02:00
parent 6a26907ded
commit cf070d48f2
9 changed files with 29 additions and 3 deletions

View File

@ -18,6 +18,7 @@ markers =
qtwebengine_todo: Features still missing with QtWebEngine
qtwebengine_skip: Tests not applicable with QtWebEngine
qtwebkit_skip: Tests not applicable with QtWebKit
qtwebengine_createWindow: Tests using createWindow with QtWebEngine (QTBUG-54419)
qt_log_level_fail = WARNING
qt_log_ignore =
^SpellCheck: .*

View File

@ -19,6 +19,7 @@
"""The main browser widget for QtWebEngine."""
import os
from PyQt5.QtCore import pyqtSignal, QUrl
# 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
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):
@ -63,6 +64,16 @@ class WebEngineView(QWebEngineView):
Return:
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)
log.webview.debug("createWindow with type {}".format(debug_type))
background = False

View File

@ -99,7 +99,7 @@ def get_fatal_crash_dialog(debug, data):
def _get_environment_vars():
"""Gather environment variables for the crash info."""
masks = ('DESKTOP_SESSION', 'DE', 'QT_*', 'PYTHON*', 'LC_*', 'LANG',
'XDG_*')
'XDG_*', 'QUTE_*')
info = []
for key, value in os.environ.items():
for m in masks:

View File

@ -132,6 +132,10 @@ if not getattr(sys, 'frozen', False):
def pytest_collection_modifyitems(config, items):
"""Apply @qtwebengine_* markers."""
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 = {
'qtwebengine_todo': ('QtWebEngine TODO', pytest.mark.xfail, webengine),
@ -139,6 +143,8 @@ def pytest_collection_modifyitems(config, items):
webengine),
'qtwebkit_skip': ('Skipped with QtWebKit', pytest.mark.skipif,
not webengine),
'qtwebengine_createWindow': ('Skipped because of QTBUG-54419',
pytest.mark.skipif, not qtbug_54419_fixed)
}
for item in items:

View File

@ -19,6 +19,7 @@ Feature: Using hints
### Opening in current or new tab
@qtwebengine_createWindow
Scenario: Following a hint and force to open in current tab.
When I open data/hints/link_blank.html
And I hint with args "links current" and follow a
@ -26,6 +27,7 @@ Feature: Using hints
Then the following tabs should be open:
- data/hello.txt (active)
@qtwebengine_createWindow
Scenario: Following a hint and allow to open in new tab.
When I open data/hints/link_blank.html
And I hint with args "links normal" and follow a
@ -34,6 +36,7 @@ Feature: Using hints
- data/hints/link_blank.html
- data/hello.txt (active)
@qtwebengine_createWindow
Scenario: Following a hint to link with sub-element and force to open in current tab.
When I open data/hints/link_span.html
And I run :tab-close
@ -151,11 +154,13 @@ Feature: Using hints
And I hint wht args "links normal" and follow a
Then "navigation request: url http://localhost:*/data/hello2.txt, type NavigationTypeLinkClicked, *" should be logged
@qtwebengine_createWindow
Scenario: Opening a link inside a specific iframe
When I open data/hints/iframe_target.html
And I hint with args "links normal" and follow a
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
When I open data/hints/iframe_target.html
And I hint with args "links tab" and follow a

View File

@ -20,6 +20,7 @@ Feature: Javascript stuff
Then "Requested to close * which does not exist!" should be logged
@qtwebkit_skip
@qtwebengine_createWindow
Scenario: Closing a JS window twice (issue 906) - qtwebengine
When I open about:blank
And I open data/javascript/issue906.html in a new tab

View File

@ -551,6 +551,7 @@ Feature: Various utility commands.
Then the page should not be scrolled
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
Given I open data/hints/link_blank.html
And I run :tab-only

View File

@ -76,6 +76,7 @@ def test_parse_fatal_stacktrace(text, typ, func):
"QT_IM_MODULE = fcitx"
),
({'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])
def test_get_environment_vars(monkeypatch, env, expected):
"""Test for crashdialog._get_environment_vars."""

View File

@ -13,7 +13,7 @@ skipsdist = true
setenv =
QT_QPA_PLATFORM_PLUGIN_PATH={envdir}/Lib/site-packages/PyQt5/plugins/platforms
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 =
-r{toxinidir}/misc/requirements/requirements-pip.txt
-r{toxinidir}/requirements.txt