From 90b0af97ce4d9f0952c201f47413a5b1bb93877d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 3 May 2017 21:31:09 +0200 Subject: [PATCH] Improve serialization crash check It now works correctly with view-source URLs and is disabled on Qt 5.9. Fixes #2289 See #2458 --- CHANGELOG.asciidoc | 1 + qutebrowser/browser/webengine/webenginetab.py | 9 ++++----- tests/end2end/features/conftest.py | 4 +++- tests/end2end/features/tabs.feature | 19 +++++++------------ tests/end2end/fixtures/quteprocess.py | 2 +- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 2d7937d22..7ff888acd 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -68,6 +68,7 @@ Fixed - Crash when unbinding an unbound key in the key config - Crash when using `:debug-log-filter` when `--filter` wasn't given on startup. - Crash with some invalid setting values +- Crash when cloning a view-source tab with QtWebEngine - Various rare crashes - Various styling issues with the tabbar and a crash with qt5ct diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 00c205b73..cc3dcf108 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -379,13 +379,12 @@ class WebEngineHistory(browsertab.AbstractHistory): def serialize(self): if not qtutils.version_check('5.9'): - # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-59599 - if self._history.count() == 0: - raise browsertab.WebTabError("Can't serialize page without " - "history!") # WORKAROUND for # https://github.com/qutebrowser/qutebrowser/issues/2289 - scheme = self._history.currentItem().url().scheme() + # Don't use the history's currentItem here, because of + # https://bugreports.qt.io/browse/QTBUG-59599 and because it doesn't + # contain view-source. + scheme = self._tab.url().scheme() if scheme in ['view-source', 'chrome']: raise browsertab.WebTabError("Can't serialize special URL!") return qtutils.serialize(self._history) diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index c65ea33ad..1e9c34462 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -174,13 +174,15 @@ def pdfjs_available(): @bdd.when(bdd.parsers.parse("I open {path}")) -def open_path(quteproc, path): +def open_path(quteproc, httpbin, path): """Open a URL. If used like "When I open ... in a new tab", the URL is opened in a new tab. With "... in a new window", it's opened in a new window. With "... as a URL", it's opened according to new-instance-open-target. """ + path = path.replace('(port)', str(httpbin.port)) + new_tab = False new_bg_tab = False new_window = False diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 748360bc3..19007428c 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -607,12 +607,19 @@ Feature: Tab management title: Test title # https://github.com/qutebrowser/qutebrowser/issues/2289 + @qtwebkit_skip @qt==5.8.0 Scenario: Cloning a tab with a special URL When I open chrome://gpu And I run :tab-clone Then the error "Can't serialize special URL!" should be shown + @qtwebkit_skip @qt<5.9 + Scenario: Cloning a tab with a view-source URL + When I open view-source:http://localhost:(port) + And I run :tab-clone + Then the error "Can't serialize special URL!" should be shown + @qtwebkit_skip @qt>=5.9 Scenario: Cloning a tab with a special URL (Qt 5.9) When I open chrome://gpu @@ -774,18 +781,6 @@ Feature: Tab management - data/numbers/2.txt - data/numbers/3.txt - # https://github.com/qutebrowser/qutebrowser/issues/2289 - @qtwebkit_skip @qt>=5.8 - Scenario: Undoing a tab with a special URL - Given I have a fresh instance - When I open data/numbers/1.txt - And I open chrome://gpu in a new tab - And I run :tab-close - And I run :undo - Then the error "Nothing to undo!" should be shown - And the following tabs should be open: - - data/numbers/1.txt (active) - # last-close # FIXME:qtwebengine diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 13d9c1043..5f99990d8 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -314,7 +314,7 @@ class QuteProc(testprocess.Process): URLs like about:... and qute:... are handled specially and returned verbatim. """ - special_schemes = ['about:', 'qute:', 'chrome:'] + special_schemes = ['about:', 'qute:', 'chrome:', 'view-source:'] if any(path.startswith(scheme) for scheme in special_schemes): return path else: