eric6/WebBrowser/WebBrowserPage.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
--- a/eric6/WebBrowser/WebBrowserPage.py	Mon Mar 01 17:48:43 2021 +0100
+++ b/eric6/WebBrowser/WebBrowserPage.py	Tue Mar 02 17:17:09 2021 +0100
@@ -57,8 +57,8 @@
     @signal sslConfigurationChanged() emitted to indicate a change of the
         stored SSL configuration data
     """
-    SafeJsWorld = QWebEngineScript.ApplicationWorld
-    UnsafeJsWorld = QWebEngineScript.MainWorld
+    SafeJsWorld = QWebEngineScript.ScriptWorldId.ApplicationWorld
+    UnsafeJsWorld = QWebEngineScript.ScriptWorldId.MainWorld
     
     safeBrowsingAbort = pyqtSignal()
     safeBrowsingBad = pyqtSignal(str, str)
@@ -146,11 +146,14 @@
         try:
             # PyQtWebEngine >= 5.14.0
             navigationType = type_ in [
-                QWebEnginePage.NavigationTypeLinkClicked,
-                QWebEnginePage.NavigationTypeRedirect
+                QWebEnginePage.NavigationType.NavigationTypeLinkClicked,
+                QWebEnginePage.NavigationType.NavigationTypeRedirect
             ]
         except AttributeError:
-            navigationType = type_ == QWebEnginePage.NavigationTypeLinkClicked
+            navigationType = (
+                type_ ==
+                QWebEnginePage.NavigationType.NavigationTypeLinkClicked
+            )
         if navigationType and url.toString().endswith(".user.js"):
             WebBrowserWindow.greaseMonkeyManager().downloadScript(url)
             return False
@@ -211,13 +214,13 @@
                 isWeb = url.scheme() in ("http", "https", "ftp", "ftps",
                                          "file")
                 globalJsEnabled = WebBrowserWindow.webSettings().testAttribute(
-                    QWebEngineSettings.JavascriptEnabled)
+                    QWebEngineSettings.WebAttribute.JavascriptEnabled)
                 if isWeb:
                     enable = globalJsEnabled
                 else:
                     enable = True
                 self.settings().setAttribute(
-                    QWebEngineSettings.JavascriptEnabled, enable)
+                    QWebEngineSettings.WebAttribute.JavascriptEnabled, enable)
                 
                 self.__channelUrl = url
                 self.__setupChannelTimer.start()
@@ -238,9 +241,9 @@
             url.scheme() == "eric" and
             not self.isJavaScriptEnabled()
         ):
-            self.settings().setAttribute(QWebEngineSettings.JavascriptEnabled,
-                                         True)
-            self.triggerAction(QWebEnginePage.Reload)
+            self.settings().setAttribute(
+                QWebEngineSettings.WebAttribute.JavascriptEnabled, True)
+            self.triggerAction(QWebEnginePage.WebAction.Reload)
     
     @classmethod
     def userAgent(cls, resolveEmpty=False):
@@ -294,7 +297,8 @@
         manager = WebBrowserWindow.featurePermissionManager()
         manager.requestFeaturePermission(self, url, feature)
     
-    def execJavaScript(self, script, worldId=QWebEngineScript.MainWorld,
+    def execJavaScript(self, script,
+                       worldId=QWebEngineScript.ScriptWorldId.MainWorld,
                        timeout=500):
         """
         Public method to execute a JavaScript function synchroneously.
@@ -302,7 +306,7 @@
         @param script JavaScript script source to be executed
         @type str
         @param worldId ID to run the script under
-        @type int
+        @type QWebEngineScript.ScriptWorldId
         @param timeout max. time the script is given to execute
         @type int
         @return result of the script
@@ -353,7 +357,7 @@
         @rtype bool
         """
         return self.settings().testAttribute(
-            QWebEngineSettings.JavascriptEnabled)
+            QWebEngineSettings.WebAttribute.JavascriptEnabled)
     
     def scroll(self, x, y):
         """

eric ide

mercurial