eric6/WebBrowser/WebBrowserPage.py

changeset 7366
bd743eacfbca
parent 7360
9190402e4505
child 7380
c99320e859ca
--- a/eric6/WebBrowser/WebBrowserPage.py	Wed Jan 08 18:57:10 2020 +0100
+++ b/eric6/WebBrowser/WebBrowserPage.py	Wed Jan 08 18:58:31 2020 +0100
@@ -9,12 +9,17 @@
 """
 
 from PyQt5.QtCore import (
-    pyqtSlot, pyqtSignal, QUrl, QUrlQuery, QTimer, QEventLoop, QPoint, QPointF
+    pyqtSlot, pyqtSignal, QUrl, QUrlQuery, QTimer, QEventLoop, QPoint, QPointF,
+    QT_VERSION
 )
 from PyQt5.QtGui import QDesktopServices
 from PyQt5.QtWebEngineWidgets import (
     QWebEnginePage, QWebEngineSettings, QWebEngineScript
 )
+try:
+    from PyQt5.QtWebEngine import PYQT_WEBENGINE_VERSION
+except AttributeError:
+    PYQT_WEBENGINE_VERSION = QT_VERSION
 from PyQt5.QtWebChannel import QWebChannel
 
 from E5Gui import E5MessageBox
@@ -124,10 +129,14 @@
                 return False
         
         # GreaseMonkey
-        if (
-            type_ == QWebEnginePage.NavigationTypeLinkClicked and
-            url.toString().endswith(".user.js")
-        ):
+        if PYQT_WEBENGINE_VERSION >= 0x50e00:       # PyQtWebEngine >= 5.14.0
+            navigationType = type_ in [
+                QWebEnginePage.NavigationTypeLinkClicked,
+                QWebEnginePage.NavigationTypeRedirect
+            ]
+        else:
+            navigationType = type_ == QWebEnginePage.NavigationTypeLinkClicked
+        if navigationType and url.toString().endswith(".user.js"):
             WebBrowserWindow.greaseMonkeyManager().downloadScript(url)
             return False
         
@@ -179,8 +188,8 @@
                 )
                 self.safeBrowsingBad.emit(threatType, "".join(threatMessages))
         
-        result = QWebEnginePage.acceptNavigationRequest(self, url, type_,
-                                                        isMainFrame)
+        result = QWebEnginePage.acceptNavigationRequest(
+            self, url, type_, isMainFrame)
         
         if result:
             if isMainFrame:

eric ide

mercurial