Permalink
Browse files

QtWebEngine: Run javascript in ApplicationWorld

This means the JS context will be isolated from the webpage itself, and
the webpage won't be able to access things we define.
  • Loading branch information...
The-Compiler committed Aug 4, 2016
1 parent a8ef956 commit 7b211e0b65b4be30347239fb0345a5df792b7f12
Showing with 4 additions and 3 deletions.
  1. +4 −3 qutebrowser/browser/webengine/webenginetab.py
@@ -26,7 +26,7 @@
from PyQt5.QtGui import QKeyEvent, QIcon
from PyQt5.QtWidgets import QApplication
# pylint: disable=no-name-in-module,import-error,useless-suppression
-from PyQt5.QtWebEngineWidgets import QWebEnginePage
+from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineScript
# pylint: enable=no-name-in-module,import-error,useless-suppression
from qutebrowser.browser import browsertab
@@ -347,10 +347,11 @@ def dump_async(self, callback, *, plain=False):
self._widget.page().toHtml(callback)
def run_js_async(self, code, callback=None):
+ world = QWebEngineScript.ApplicationWorld
if callback is None:
- self._widget.page().runJavaScript(code)
+ self._widget.page().runJavaScript(code, world)
else:
- self._widget.page().runJavaScript(code, callback)
+ self._widget.page().runJavaScript(code, world, callback)
def run_js_blocking(self, code):
unset = object()

0 comments on commit 7b211e0

Please sign in to comment.