Improve serialization crash check

It now works correctly with view-source URLs and is disabled on Qt 5.9.

Fixes #2289
See #2458
This commit is contained in:
Florian Bruhin 2017-05-03 21:31:09 +02:00
parent ea2d5e97e2
commit 90b0af97ce
5 changed files with 16 additions and 19 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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: