diff options
author | toofar <toofar@spalge.com> | 2023-03-18 16:24:58 +1300 |
---|---|---|
committer | toofar <toofar@spalge.com> | 2023-03-18 16:24:58 +1300 |
commit | 856fe781a1ce5cbe8033894fce3166d46ab5439e (patch) | |
tree | 446f274e33aa0cab9bf5b60e32dcf0e90c1fbf41 | |
parent | 1c4b5cc3d202a2eb960114eecb04d7bf236b7ac1 (diff) | |
parent | cd5624f50ad92317868514ad5b024a58dbdb233c (diff) | |
download | qutebrowser-856fe781a1ce5cbe8033894fce3166d46ab5439e.tar.gz qutebrowser-856fe781a1ce5cbe8033894fce3166d46ab5439e.zip |
Merge remote-tracking branch 'upstream/qt6-v2' into master-qt6
-rw-r--r-- | doc/help/settings.asciidoc | 2 | ||||
-rw-r--r-- | pytest.ini | 3 | ||||
-rw-r--r-- | qutebrowser/mainwindow/tabwidget.py | 26 | ||||
-rwxr-xr-x | scripts/asciidoc2html.py | 7 | ||||
-rw-r--r-- | tests/conftest.py | 2 | ||||
-rw-r--r-- | tests/end2end/fixtures/quteprocess.py | 65 | ||||
-rw-r--r-- | tests/end2end/test_invocations.py | 16 | ||||
-rw-r--r-- | tests/unit/mainwindow/test_tabwidget.py | 35 | ||||
-rw-r--r-- | tests/unit/misc/test_elf.py | 6 |
9 files changed, 146 insertions, 16 deletions
diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 29cde3b0f..0967c069b 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -2779,8 +2779,6 @@ Valid values: * +js-whatsapp-web+ * +js-discord+ * +js-string-replaceall+ - * +js-globalthis+ - * +js-object-fromentries+ * +js-array-at+ * +misc-krunker+ * +misc-mathml-darkmode+ diff --git a/pytest.ini b/pytest.ini index ab46bd391..82f700461 100644 --- a/pytest.ini +++ b/pytest.ini @@ -54,6 +54,9 @@ qt_log_ignore = # tests/unit/commands/test_userscripts.py::test_killed_command # on Windows ^QProcess: Destroyed while process .* is still running\. + # Qt 6.5 debug build + # WORKAROUND for https://www.riverbankcomputing.com/pipermail/pyqt/2023-March/045215.html + ^QObject::connect: Connecting from COMPAT signal \(QSocketNotifier::activated\(int\)\)$ xfail_strict = true filterwarnings = error diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 5e4f519fa..580da64b4 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -405,7 +405,8 @@ class TabBar(QTabBar): def __init__(self, win_id, parent=None): super().__init__(parent) self._win_id = win_id - self.setStyle(TabBarStyle()) + self._our_style = TabBarStyle() + self.setStyle(self._our_style) self.vertical = False self._auto_hide_timer = QTimer() self._auto_hide_timer.setSingleShot(True) @@ -696,6 +697,29 @@ class TabBar(QTabBar): qtutils.ensure_valid(size) return size + def initStyleOption(self, opt, idx): + """Override QTabBar.initStyleOption(). + + Used to calculate styling clues from a widget for the GUI layer. + """ + super().initStyleOption(opt, idx) + + # Re-do the text elision that the base QTabBar does, but using a text + # rectangle computed by out TabBarStyle. With Qt6 the base class ends + # up using QCommonStyle directly for that which has a different opinon + # of how vertical tabs should work. + text_rect = self._our_style.subElementRect( + QStyle.SubElement.SE_TabBarTabText, + opt, + self, + ) + opt.text = self.fontMetrics().elidedText( + self.tabText(idx), + self.elideMode(), + text_rect.width(), + Qt.TextFlag.TextShowMnemonic, + ) + def paintEvent(self, event): """Override paintEvent to draw the tabs like we want to.""" p = QStylePainter(self) diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py index 6f3b170af..a7816e132 100755 --- a/scripts/asciidoc2html.py +++ b/scripts/asciidoc2html.py @@ -84,12 +84,15 @@ class AsciiDoc: dst = DOC_DIR / (src.stem + ".html") files.append((src, dst)) - # patch image links to use local copy replacements = [ + # patch image links to use local copy ("https://raw.githubusercontent.com/qutebrowser/qutebrowser/master/doc/img/cheatsheet-big.png", "qute://help/img/cheatsheet-big.png"), ("https://raw.githubusercontent.com/qutebrowser/qutebrowser/master/doc/img/cheatsheet-small.png", - "qute://help/img/cheatsheet-small.png") + "qute://help/img/cheatsheet-small.png"), + + # patch relative links to work with qute://help flat structure + ("link:../", "link:"), ] asciidoc_args = ['-a', 'source-highlighter=pygments'] diff --git a/tests/conftest.py b/tests/conftest.py index f875ac3d9..622286a54 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -212,7 +212,7 @@ def qapp_args(): """Make QtWebEngine unit tests run on older Qt versions + newer kernels.""" if testutils.disable_seccomp_bpf_sandbox(): return [sys.argv[0], testutils.DISABLE_SECCOMP_BPF_FLAG] - return [] + return [sys.argv[0]] @pytest.fixture(scope='session') diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index df3a15ff1..9b0f20009 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -61,6 +61,18 @@ def is_ignored_lowlevel_message(message): # Qt 6.4, from certificate error below, but on separate lines '----- Certificate i=0 (*,CN=localhost,O=qutebrowser test certificate) -----', 'ERROR: No matching issuer found', + + # Qt 6.5 debug, overflow/linebreak from a JS message... + # IGNORED: [678403:678403:0315/203342.008878:INFO:CONSOLE(65)] "Refused + # to apply inline style because it violates the following Content + # Security Policy directive: "default-src none". Either the + # 'unsafe-inline' keyword, a hash + # ('sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='), or a nonce + # ('nonce-...') is required to enable inline execution. Note also that + # 'style-src' was not explicitly set, so 'default-src' is used as a + # fallback. + # INVALID: ", source: userscript:_qute_stylesheet (65) + '", source: userscript:_qute_stylesheet (65)', ] return any(testutils.pattern_match(pattern=pattern, value=message) for pattern in ignored_messages) @@ -130,6 +142,59 @@ def is_ignored_chromium_message(line): 'CertVerifyProcBuiltin for localhost failed:', # [320667:320667:1124/135621.718232:ERROR:interface_endpoint_client.cc(687)] Message 4 rejected by interface blink.mojom.WidgetHost 'Message 4 rejected by interface blink.mojom.WidgetHost', + + + # Qt 5.15.1 debug build (Chromium 83) + # '[314297:7:0929/214605.491958:ERROR:context_provider_command_buffer.cc(145)] + # GpuChannelHost failed to create command buffer.' + # Still present on Qt 6.5 + 'GpuChannelHost failed to create command buffer.', + + # Qt 6.5 debug build + # [640812:640865:0315/200415.708148:WARNING:important_file_writer.cc(185)] + # Failed to create temporary file to update + # /tmp/qutebrowser-basedir-3kvto2eq/data/webengine/user_prefs.json: No + # such file or directory (2) + # [640812:640864:0315/200415.715398:WARNING:important_file_writer.cc(185)] + # Failed to create temporary file to update + # /tmp/qutebrowser-basedir-3kvto2eq/data/webengine/Network Persistent + # State: No such file or directory (2) + 'Failed to create temporary file to update *user_prefs.json: No such file or directory (2)', + 'Failed to create temporary file to update *Network Persistent State: No such file or directory (2)', + + # Qt 6.5 debug build + # [645145:645198:0315/200704.324733:WARNING:simple_synchronous_entry.cc(1438)] + "Could not open platform files for entry.", + + # Qt 6.5 debug build + # [664320:664320:0315/202235.943899:ERROR:node_channel.cc(861)] + # Dropping message on closed channel. + "Dropping message on closed channel.", + + # Qt 6.5 debug build + # tests/end2end/features/test_misc_bdd.py::test_webrtc_renderer_process_crash + # [679056:14:0315/203418.631075:WARNING:media_session.cc(949)] RED + # codec red is missing an associated payload type. + "RED codec red is missing an associated payload type.", + + # Qt 6.5 debug build + # tests/end2end/features/test_javascript_bdd.py::test_error_pages_without_js_enabled + # and others using internal URL schemes? + # [677785:1:0315/203308.328104:ERROR:html_media_element.cc(4874)] + # SetError: {code=4, message="MEDIA_ELEMENT_ERROR: Media load rejected + # by URL safety check"} + 'SetError: {code=4, message="MEDIA_ELEMENT_ERROR: Media load rejected by URL safety check"}', + + # Qt 6.5 debug build + # [714871:715010:0315/205751.155681:ERROR:surface_manager.cc(419)] + # Old/orphaned temporary reference to SurfaceId(FrameSinkId[](14, 3), + # LocalSurfaceId(3, 1, 5D04...)) + "Old/orphaned temporary reference to SurfaceId(FrameSinkId[](*, *), LocalSurfaceId(*, *, *...))", + + # Qt 6.5 debug build + # [758352:758352:0315/212511.747791:WARNING:render_widget_host_impl.cc(280)] + # Input request on unbound interface + "Input request on unbound interface", ] return any(testutils.pattern_match(pattern=pattern, value=message) for pattern in ignored_messages) diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py index 415aa5020..ce38eec24 100644 --- a/tests/end2end/test_invocations.py +++ b/tests/end2end/test_invocations.py @@ -663,20 +663,20 @@ def test_cookies_store(quteproc_new, request, short_tmpdir, store): 'blank', 'lightness-hsl', { - # FIXME:qt6 Why #121212 rather than #000000? - ('6.4', None): testutils.Color(18, 18, 18), - ('6.3', None): testutils.Color(18, 18, 18), - (None, None): testutils.Color(0, 0, 0), + ('5.15', None): testutils.Color(0, 0, 0), + ('6.2', None): testutils.Color(0, 0, 0), + # Qt 6.3+ (why #121212 rather than #000000?) + (None, None): testutils.Color(18, 18, 18), } ), ( 'blank', 'brightness-rgb', { - # FIXME:qt6 Why #121212 rather than #000000? - ('6.4', None): testutils.Color(18, 18, 18), - ('6.3', None): testutils.Color(18, 18, 18), - (None, None): testutils.Color(0, 0, 0) + ('5.15', None): testutils.Color(0, 0, 0), + ('6.2', None): testutils.Color(0, 0, 0), + # Qt 6.3+ (why #121212 rather than #000000?) + (None, None): testutils.Color(18, 18, 18), } ), diff --git a/tests/unit/mainwindow/test_tabwidget.py b/tests/unit/mainwindow/test_tabwidget.py index db300d7a6..d6289dac6 100644 --- a/tests/unit/mainwindow/test_tabwidget.py +++ b/tests/unit/mainwindow/test_tabwidget.py @@ -23,8 +23,9 @@ import functools import pytest -from qutebrowser.qt.gui import QIcon, QPixmap +from unittest.mock import Mock +from qutebrowser.qt.gui import QIcon, QPixmap from qutebrowser.mainwindow import tabwidget from qutebrowser.utils import usertypes @@ -71,6 +72,38 @@ class TestTabWidget: assert first_size == widget.tabBar().tabSizeHint(i) assert first_size_min == widget.tabBar().minimumTabSizeHint(i) + @pytest.fixture + def paint_spy(self, monkeypatch): + spy = Mock() + monkeypatch.setattr(tabwidget, "QStylePainter", spy) + return spy + + def test_tab_text_edlided_for_narrow_tabs(self, paint_spy, widget, fake_web_tab): + """Make sure text gets elided for narrow tabs.""" + widget.setMaximumWidth(100) + widget.addTab(fake_web_tab(), "one two three four") + + fake_paint_event = Mock() + fake_paint_event.region.return_value.intersects.return_value = True + widget.tabBar().paintEvent(fake_paint_event) + + style_opt = paint_spy.return_value.drawControl.call_args_list[0][0][1] + assert len(style_opt.text) < len(widget.tabBar().tabText(0)) + assert style_opt.text.endswith("…") + assert len(style_opt.text) > len("…") + + def test_tab_text_not_edlided_for_wide_tabs(self, paint_spy, widget, fake_web_tab): + """Make sure text doesn't get elided for wide tabs.""" + widget.setMaximumWidth(200) + widget.addTab(fake_web_tab(), "one two three four") + + fake_paint_event = Mock() + fake_paint_event.region.return_value.intersects.return_value = True + widget.tabBar().paintEvent(fake_paint_event) + + style_opt = paint_spy.return_value.drawControl.call_args_list[0][0][1] + assert style_opt.text.endswith(widget.tabBar().tabText(0)) + @pytest.mark.parametrize("shrink_pinned", [True, False]) @pytest.mark.parametrize("vertical", [True, False]) def test_pinned_size(self, widget, fake_web_tab, config_stub, diff --git a/tests/unit/misc/test_elf.py b/tests/unit/misc/test_elf.py index 8a89d11fb..41a5e273d 100644 --- a/tests/unit/misc/test_elf.py +++ b/tests/unit/misc/test_elf.py @@ -47,7 +47,7 @@ def test_format_sizes(fmt, expected): @pytest.mark.skipif(not utils.is_linux, reason="Needs Linux") -def test_result(qapp, caplog): +def test_result(webengine_versions, qapp, caplog): """Test the real result of ELF parsing. NOTE: If you're a distribution packager (or contributor) and see this test failing, @@ -60,6 +60,10 @@ def test_result(qapp, caplog): pytest.importorskip('qutebrowser.qt.webenginecore') versions = elf.parse_webenginecore() + if webengine_versions.webengine == utils.VersionNumber(6, 5): + assert versions is None + pytest.xfail("ELF file structure not supported") + assert versions is not None # No failing mmap |