This commit is contained in:
Kovid Goyal 2021-12-15 08:15:26 +05:30
parent 4669ca7d8b
commit 8c2aa4182c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 5 deletions

View File

@ -341,12 +341,13 @@ class WebPage(QWebEnginePage):
prints('%s:%s: %s' % (source_id, linenumber, msg))
def acceptNavigationRequest(self, url, req_type, is_main_frame):
if req_type == QWebEngineUrlRequestInfo.NavigationType.NavigationTypeReload:
if req_type in (QWebEngineUrlRequestInfo.NavigationType.NavigationTypeReload, QWebEngineUrlRequestInfo.NavigationType.NavigationTypeBackForward):
return True
if url.scheme() in (FAKE_PROTOCOL, 'data'):
return True
if req_type == QWebEnginePage.NavigationType.NavigationTypeLinkClicked:
if url.scheme() in ('http', 'https') and req_type == QWebEnginePage.NavigationType.NavigationTypeLinkClicked:
safe_open_url(url)
prints('Blocking navigation request to:', url.toString())
return False
def go_to_anchor(self, anchor):

View File

@ -370,9 +370,7 @@ class WebPage(QWebEnginePage):
pass
def acceptNavigationRequest(self, url, req_type, is_main_frame):
if req_type == QWebEngineUrlRequestInfo.NavigationType.NavigationTypeReload:
return True
if req_type == QWebEngineUrlRequestInfo.NavigationType.NavigationTypeBackForward:
if req_type in (QWebEngineUrlRequestInfo.NavigationType.NavigationTypeReload, QWebEngineUrlRequestInfo.NavigationType.NavigationTypeBackForward):
return True
if url.scheme() in (FAKE_PROTOCOL, 'data'):
return True