Implement a better workaround for chrome-error:// URLs

It looks like chrome-error://chromewebdata/ triggers another invalid scheme
load which is why the endless loop happens. When we install a custom scheme
handler for chrome-error:// we can at least show an error page.
This commit is contained in:
Florian Bruhin 2018-06-07 16:03:25 +02:00
parent c6a1d729f4
commit b1506274c5
2 changed files with 10 additions and 7 deletions

View File

@ -19,7 +19,7 @@
"""QtWebEngine specific qute://* handlers and glue code."""
from PyQt5.QtCore import QBuffer, QIODevice
from PyQt5.QtCore import QBuffer, QIODevice, QUrl
from PyQt5.QtWebEngineCore import (QWebEngineUrlSchemeHandler,
QWebEngineUrlRequestJob)
@ -34,6 +34,9 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler):
def install(self, profile):
"""Install the handler for qute:// URLs on the given profile."""
profile.installUrlSchemeHandler(b'qute', self)
if qtutils.version_check('5.11', compiled=False):
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-63378
profile.installUrlSchemeHandler(b'chrome-error', self)
def requestStarted(self, job):
"""Handle a request for a qute: scheme.
@ -45,6 +48,12 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler):
job: QWebEngineUrlRequestJob
"""
url = job.requestUrl()
if url.scheme() == 'chrome-error':
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-63378
job.fail(QWebEngineUrlRequestJob.UrlInvalid)
return
assert job.requestMethod() == b'GET'
assert url.scheme() == 'qute'
log.misc.debug("Got request for {}".format(url.toDisplayString()))

View File

@ -1030,12 +1030,6 @@ class WebEngineTab(browsertab.AbstractTab):
if not ok and not js_enabled:
self.dump_async(self._error_page_workaround)
if (not ok and
self.url() == QUrl('chrome-error://chromewebdata/') and
qtutils.version_check('5.11', compiled=False)):
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-63378
self._show_error_page(QUrl(), "Unknown URL scheme")
if ok and self._reload_url is not None:
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-66656
log.config.debug(